A part of your payments will indeed build equity, but over 30 years of payments, most of it won't (see previous comment).
If the market crashes, your house will not remain yours if you can't afford making payments. If things go south, I see unavoidable payments and illiquid assets as a liability, not an asset.
Selling is indeed tax-advantaged after a few years though. That's a good point.
The main pro for me is that it's a hedge against rent prices and inflation. However that's assuming that housing prices are reasonable, and that there are no better investments.
However, in terms of building equity (not to become a small-time landlord), buying an apartment is a safe bet - the housing market has been in a bull market for a long time, and the last few years have been especially good. I suspect we're closer to a long-term top than many think, but that's another matter. Even if the market crashes, your house remains yours and keeps providing shelter. On top of that, selling is tax-advantaged whereas stocks aren't.