You cannot always sell the house. The market may have fallen, or rates may have risen in a way that makes your home less affordable. Also, prematurely paying off your mortgage might have punishing penalties, and also there are frictional costs to selling.
You cannot always necessarily rent to others. You may have strata / HOA rules that prevent renting.
Buying with cash has an opportunity cost on your money. A mortgage is renting money. Whether you rent a home or you rent money, either way you're paying rent. You also have other "lost money" costs as an owner: maintenance costs (and labour), property taxes, possibly condo fees, etc. So when you consider the "losing money" aspect of owning, you're losing the interest payments, and you're losing some other fees... but the part of your mortgage payment that is excess of interest is not lost money (it's savings).
On other other hand, there are advantages to owning. In particular, if you want to make a highly leveraged wager (5x being common), you can do that in real estate. If you win at the wager, you can win a lot of money. (Of course a casino lets you win a lot of money too, with extreme leverage, but the housing market has no "house" extracting a vig, pun not intended). Also, many countries have tax incentives for ownership. For example, US effective interest rates are somewhat lower than the contractual rate, because the government gives you some of it back at tax time (I think.... I'm not an ardent student of the US housing rules).
In short, a statement like "you've always got options as an owner" or "renting is losing while buying is an investment" is so oversimplified as to be incredibly damaging.
The math is tractable for a modestly smart person, but it does take some dedication.