I was raised to never buy new and never lease, that a new car loses x% of its value the minute you drive it off the lot, etc. I think a lot of that has changed now for a few reasons.
First, the creation of CPO programs. Being able to buy an almost-new car with a full warranty is a good value prop, and seriously eats away at the money you save from buying used. Second, the complexity of cars today versus 20 years ago is significant. Safety systems, cameras, drive-by-wire, electronics - so much of the systems are integrated you can have a minor issue and it's $500+ easy.
Finally, most folks these days are going to finance a purchase. If you're going to buy a car in cash you can disregard this, but you can typically get much lower rates on new cars than used, and that also helps drive the CPO market. Especially with the used car market being so crazy right now, when you add up money saved on interest and maintenance if really can be straight up more affordable to buy new.
As for leasing vs buying, I think you just have to grind the numbers. Some lease deals are truly terrible, some are extremely good. And don't overlook your end-of-lease options. I leased my current car pre-pandemic (first lease ever), and the buy-out at the end was like $10k less than the value of the car now so I just bought it. The rate built into the lease when I got it was so far below the purchase rate that it made more sense to lease-then-buy vs buying it to start. In hindsight it was an even better deal that I expected. There are often some hidden fees, costs, and extras built into leases, so I ended up building a spreadsheet to track them all.
Final piece to me is just how much you care about or enjoy newer cars. I got caught once with an older car that kept bleeding money - timing belt here, water pump there - I could have covered a year of lease payments with the cost of the repairs. Plus it was old and boring. I swore to never do that again, but definitely know plenty of folks who just want to spend as little as possible on cars and don't care. Once the deals on new cars got into the "pretty close" range it was no-brainer to me.