Because people want to live there while they have a career and raise a family.
Setting that aside, it’s not a Ponzi scheme when anyone can sell their security. You’re probably thinking of the Greater Fool Theory.
Either way, it’s still not correct because making money isn’t the primary reason everyone is buying homes in the Bay Area at least. They need a place to live and don’t want rent to go up in perpetuity.