The Bay Area has a number of little-known unincorporated enclaves that are often located within incorporated cities. Places like Devonshire (San Carlos), Emerald Hills (Redwood City), the unincorporated strip of San Carlos Ave (San Jose), Ladera or Los Trancos Woods (Portola Valley), Castro Valley and San Lorenzo (Hayward/Oakland). I've noticed that in today's hot market, houses in those areas consistently go for anything for $0-150K under asking, while houses in the nearby cities go for $150-500K over asking. A typical swing in purchase price for equivalent homes in nearly equivalent locations is about $300K (on prices of about $1.8-2.2M).
The usual real-estate confounders don't apply here because the geographic locations are so similar. The fire danger is roughly equivalent (but high): places like Devonshire and Emerald Hills are inside of 280, and right next door to equally flammable but more expensive houses in Belmont, San Carlos, and Redwood City. Commute times are basically identical, if anything a little shorter. There's less regulation for building, but not much more additional supply of land since these are constrained enclaves.
It seems like buyers are willing to pay a premium specifically to get city services and city regulation. Instead of the free market being impeded, this is the free market speaking: buyers are paying a premium to live in areas where there are more services and more regulation.
I can think of another difference: loads of people want to live where they do, pushing up prices, while few people want to live where you do, keeping prices reasonable.
I'm not a hard-right libertarian--I think healthcare probably has some examples of market failures and maybe we need something like universal catastrophic insurance. But yeah, some of these problems, like housing costs, really are self-inflicted.
I think the other approach is to shift blame or sweep under the rug problems with services that are entirely publicly run. If you have a problem with the schools or police in your blue city/state, 90% of your energy should be directed to your own state and local officials! (Instead of railing against Jeff Bezos or Donald Trump.)