In practice, HOAs generally don't do anything useful, though.
How?
Feels really odd, no one in our area actually wants an HOA. Yet i think people are going to flip when their HOA dues are suddenly required by the city and at much steeper rates (i imagine 2-4x the cost, our dues are quite small atm).
The real, completely arbitrary thing that makes housing expensive is zoning. There is research on this. Zoning, especially in the long term, has enormous effects, including on things seemingly unrelated such as reducing construction productivity, reducing competition among construction firms (fewer contractors) and reducing housing supply (supply vs demand).
I think people generally don’t appreciate how restrictive zoning effectively is. It’s not just what you can build, but how big it is, layout things, and can even reach into aesthetics etc.