Why is a living near the same people you know and love irrational or somehow an inappropriate object of economic reasoning? You could even estimate prices for such things! Just because they're not typically represented as currency amounts doesn't mean they're not 'rationally economic' or that making tradeoffs that involve these things couldn't be better done with good economics.
You are correct that it is fully rational behavior for people. However that is not the definition used in economics. (sort of like physics tends to assume no friction where possible)
[1]: https://en.wikipedia.org/wiki/Von_Neumann–Morgenstern_utilit...
* https://www.axios.com/sky-high-home-prices-are-thwarting-thw...
* https://www.citylab.com/equity/2017/06/the-other-side-of-har...
Cf. China, which has seen unbelievably explosive growth in its cities in the last 40 years and China has also seen ~1 billion people lifted out of poverty during exactly the same time period.
In all but the smallest cities you have options for a different job. They might not be as good, but there is an option. If you lose your job you can find a different job close enough to your current house that you don't have to move.
Remember this is NOT an rational economic problem. There are good reasons to live near by the same neighbors that you know well for years. There are good reasons to live near your family. When you own a house you can make modifications to support your hobbies which in turn make your house a better place for your to live than anyone else. These all mean there are good reasons to accept a job that pays less than you could earn elsewhere and thus stay in the same house. With inflation you can probably afford the house on a lesser paying job after a few years.