Land is mostly a set resource with new developments and cities slowing. Home development follows land and while there’s been a boom, overall it’s been slowing. As there are more people, demand for housing increases.
All of this drives cost of homes up. So the longer you are in a home, the more it and/or the land it worth. Usually outpacing inflation. So when you sell, it’s worth more. It’s an investment by default even for those people who own 1 normal-sized single family home. It was an investment even when housing prices were reasonable decades ago.