Should I Purchase a Used Luxury Car or Lease Something New?

I'm trying to decide between purchasing a used 2022+ Mercedes C-Class or leasing something new. My budget for purchasing is around $35K. I'd love to hear your thoughts on buying a car like this. I've heard that buying used luxury cars often comes with the risk of issues and expensive repairs. Since many of these cars can be lease returns (I'm in NYC), they might not have been well-maintained, which could lead to costly fixes down the road.

I'm also thinking about the long-term financial impact. If I lease, after a 3-year term, I’d end up spending around $20K, give or take. If I lease another car after that, it would cost me another $20K, so over the next 6 years, I’d be out of pocket around $40K with nothing to show for it. On the other hand, if I buy a used C-Class now for about $35K, I’ll still have a car/something of value after 6 years that I can sell, trade in, or keep.

What are your thoughts? Do you think it’s better to lease new or buy a used luxury car? Any advice or suggestions would be greatly appreciated. Thanks!