But the scenario you’re illustrating is very rare. RE never goes to zero
Neither do mutual funds.
Of course, individual stock can go to zero, but you can sell and cut your losses with about 45 seconds of mouseclicking effort. Real estate, especially depreciating real estate, not so much. And unless you're buying on margin, you can never be underwater with stocks and unable to sell. Sometimes you can short-sale a property but then the bank's 1099 will just turn their problem into the IRS's problem, and the IRS always gets its money.
Depreciating real estate purchased on credit and depreciating equities purchased with cash are not the same thing.
Also, residents near Chernobyl might disagree about real estate never going to zero. Or anyone near a superfund site. Or a war zone. All obviously very unlikely in the USA ... but one of the intrinsic risks of RE is the relative lack of diversification, and the way real estate holdings typically constitute an enormous portion of a RE investor's portfolio. RE is tied to the fortunes of a single location, a single school district, a single collection of neighbors who might run a meth lab or put a couple Trans Ams up on blocks in the yard, a single town's economy.
If you want to accept all of these risks in exchange for what you think are higher real returns (despite evidence to the contrary, as noted by Mman), more power to you, but don't pretend those risks don't exist.