Your own argument is that you need a roof over your head, either way, so if the value doesn't increase, then you simply live there. If it does, then you keep all the profit, tax free.
Yes, you probably shouldn't buy a house if you imagine you'll want or need to move in the next 7-10 years. And, yes, it's also not the case that there is zero risk. It's just lots of leverage with favorable tax treatment. But it's not a magic money machine.
Find yourself at a peak and you could be stuck for years to come.
Again, this was all about asymmetric upside. Being unable to move even as life circumstances change seems like a pretty sharp downside.