> As if you do that for 10 years you have 4M dollars, 20 years?
If you're making 400k post-tax, sure. If that's pre-tax income, however, you're not making 4M after 10 years.
After federal taxes you're making closer to $286k, roughly. This is just for the privilege of being a US citizen - even if you don't necessarily spend the majority of your time in the country.
Assuming this is a CA software engineer, it's closer to $250k. This is just for the privilege of having a tax basis in CA.
Assuming you actually do live in the Bay Area as a single bachelor and would like the privilege of having your own apartment that you don't have to share with others (remember, you're "rich") a nice unit to yourself will run you roughly $3k/m -> $24k/y. So we're much closer to $225k/y.
Even assuming this person has no car, no social life, and no metabolism we're still running at roughly half of your projections. Which is still a fair chunk, to be sure. But it's still half of their money going towards the privilege of obtaining money.
EDIT: just saw this bit
> I get that COL lowers that, but if you are making 400K you're not renting
This depends, as buying is not always superior to renting, especially when you're talking a house. A house is a pretty big investment - so much so that a lot of financial circles still spend a lot of time between "get a home, what isn't equity is a tax write off" and "just rent, no surprise expenses, remain more liquid, invest the difference between your rent and a typical mortgage in the market".
The last time I was looking in the South Bay area, average prices for a 2 bedroom home in a suburb were ~$1.2m. This is a $240k down payment and ~$7.3k monthly (15 year conventional, down to ~$4.7 for 30 year but we're outside of the "10/20 years" we described above and paying more interest for it besides).
If we account for all that, we're looking at much closer to $190k being available to us after the privilege of living and working (that's adjusting for the taxes, but it's not so clean as interest is a sliding scale over the years) - just now we have a place to ourselves that cost us around a year or two of savings time just to start the house purchase and a recurring expense that's over double the nearby rent. This is largely not favorable to the majority of people unless they're wanting to lay roots. That said, given people seem to be leaving I'd imagine housing prices will become less steep in a matter of years; albeit whether it makes it more reasonable to buy than rent for those not looking to stay for 15+ years remains something of an open question.