if the easiest way to make money is to rent houses in a captured market because the local regulations prevent the building of more housing, that's what they'll do. if the easiest way to make more money is to build more housing because the regulations allow for the building of housing, they'll do that too. the problem isn't the developers, they're where the housing comes from. the problem is that at every turn, there's people actively fighting against the buliding of more housing. all they're doing is making money off that situation.
For instance, suppose they build 100 apartments in the suburb of X. They know that for every $1k the price of housing in X drops, they lose $100k. So weirdly, they tend to leave housing vacant and sell it at a drip-feed so that they're always selling less houses than there are buyers - there is a huge difference between selling 3 apartments to 4 buyers, vs selling 4 apartments to 4 buyers. This particularly bad when there are few, large developers instead of lots of small developers, as the few large developers can collude to price-fix much easier.
Please don't interpret this as contradicting the fact that California needs to massively overhaul its zoning/construction permit system - the fact that it can take years to receive permission instead of weeks is a big reason for the price of housing (and raises capex requirements which results in fewer but larger developers, see previous paragraph). Ditto for all the zoning that mandates exclusively single-family homes, and other such pointless exclusionism.
But painting NIMBYism in such reductionist (and long-term economic-investment backward) as "development would make real estate investors and developers lose money" would just result in people fighting entirely the wrong battles with entirely the wrong message to actually have a chance at changing things in a useful way.
Seattle and NYC are both examples of places that funnel all development into a select few areas where the market for land is cornered.
If there is only a limited supply of land to build further on, it is much easier to corner said market of land and sit on it if the prices are not high enough for your liking. The cheapest development is the kind that larger developers do not bother with (one house to two or three on a single plot of land, rather than large complexes)