This has been repeated ad nauseum but if it were correct all businesses would always strive to buy their real estate as soon as they could afford it and since many (including my employer, who brings in a billion dollars a year) are content renting long term, that's obviously not the case.
If you buy once you factor in taxes, insurance, upgrades, maintenance, repairs, commission, closing costs, opportunity costs compared to other investments, interest, PMI, etc., assuming you were in a good financial position to buy in the first place so you don't default, you probably will come out ahead compared to renting if you live in your house for more than 5 or so years.
But! That's only if the cards fall just right. So if the neighborhood is still desirable, tax policy/political landscape doesn't change, your neighbors keep up with their maintenance, your HoA doesn't go into bankruptcy, a major employer doesn't leave town, tastes in housing doesn't change, the housing market doesn't crash, too many of your neighbors don't foreclose, nearby amenities don't leave, a major highway isn't built through your neighborhood, interest rates haven't soared, political housing incentives/programs haven't gone away, too many black people don't move in(1), etc., etc. You're taking on a very large risk if your buying vs renting, sure it has the ability to work in your favor (extreme example - buying in San Francisco in the 90s) or not in your favor (extreme example - buying in Detroit in the 50s).
I've seen people lose out terribly financially buying a house, and not just in 2008 recession, my parents house was bought in 1995 and hasn't even kept up with inflation. That doesn't mean it was the wrong choice for them to buy though, houses are really good at providing shelter.
You also have to have the ability and wherewithal to take care of a house - and tons of people don't.
I'm a homeowner, I'm not against home ownership.
(1) I'm not trying to be racist, but white flight does exist.