For people living in an expensive apartment, they might be barely making rent. Whereas they could obviously afford a mortgage for a similar monthly amount - but since they're living paycheck-to-paycheck they can't save the prodigious 20%. So they're stuck.
Of course perhaps some people have a nest-egg from a windfall or inheritance but then couldn't handle the monthly payment.
The main barrier these days to putting less down is twofold - one, you need to pay PMI which is just compounding the monthly payment problem. Two, good fricking luck getting your offer accepted with <20% down in these times. Sellers read into offers more than just "is this financed y/n" and there's IMMENSE preference for buyers who can put 20% down, because it signals that a) if necessary they could pay PMI and drop down the up-front % in order to close on a contract, and b) they probably have more cash than just that 20% and are only stopping at 20% because it is customary and they could weather unforeseen issues more easily.
To put it in anecdote form: I sold my house in 2020. We had 8 offers presented to us after 1 day on the market. All were for 20% down because my agent didn't even hear offers from people with less down, since we had so many at 20%. In mid-2023, my brother bought a house in a similar sort of area (metro area of a major-for-the-midwest city). 2 days on the market, he was one of 3 offers, all for 20% down and about 50k over asking (the house was priced somewhat low as a marketing strategy, but I'm guessing based on comps they still had to go in about 10k over a non-meme version of the list price). He wouldn't have even been in the running if he didn't have 20% down. And he also had to waive all contingencies which almost made his financing fall through/be late due to something stupid a random inspector said.
It's tough out there. Even if you can nominally "afford" a house, it can be hard to actually close on one in the open market without someone more financially established who is able to backstop you in various ways.