I bought as much as I could afford, but my budget included savings and a cushion. The bank would have loaned me plenty more than what my budget could afford. And my budget included repairs and maintenance. I also included in my budget a 4 bedroom house costs more than a 900 sqft town house to heat and cool. The big thing was I wasn't willing to give up maxing out our retirement accounts.
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.
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.
There's a lot of evidence that shows that for every dollar of loans made available to students, the price of education rises, and that's a system without supply/demand dynamics since admissions aren't (supposed to be) based on a bidding process. It seems only reasonable to conclude that the availability of mortgages has similarly increased the price of housing. It's a hidden cost of our housing market that banks (and a few others) profit by. The banks loan fictional money, created out of thin air thanks to fractional lending requirements, and collect a percentage of that back every year on a house that only costs what it does because of that loan. Without mortgages, people would be forced to save up and the price of housing would be governed more by the cost of actually constructing houses and the amount that people were able to save before buying rather than a percentage of their income over the next 30 years.
Think, for example, if banks decided to change the standard loan time from 30 years to 40 years. What would happen to housing prices in areas with somewhat constrained supply? Homebuyers would still look at monthly payments and buy as much house as they could afford. So housing prices would increase accordingly and instead of mortgaging 30 years of our futures, we'd be mortgaging 40. We'd be buying the same houses and banks would be making more money. Change 30 years to 20 years and you'd get a similar drop in housing prices.
More than any other thing that we spend money on these days, housing prices have been decoupled from their cost of production and banks are largely the ones skimming that difference between what housing should cost and what it actually costs.
But in practice, "as good as you can afford" really means "buy the lead paint, lead water, asbestos ridden, foundation broken 'cheap' house? Or buy the no-lead, no asbestos, no mold 'expensive' house? "As good as you can afford" actually translates to the "least shitty" option, for most people.
Buying an 8 bedroom house just because the bank will technically let you, is a fun TV sitcom joke. Not a real thing most people are ever able to actually do.
If you grew up in a modest but well-kept house in a decent neighborhood, that is your baseline. If you then go on to reach some level of success in your career such that you are roughly on par or exceeding your parents income, your expectation naturally is that you should be able to afford something similar or better. Unfortunately the market dynamics have completely shifted since parents bought, and so people are having to take a really harsh look at the reality of their past expectations and how they align with their current reality. It often means paying way more than they ever wanted or thought was necessary to buy something way crappier.
Early movers purchase a higher grade of home than they could have previously. Eventually this shifts the market as a whole as income distribution remains stable. Then people buy the same house they would have previously at a higher price. Now nothing has changed and people are more in debt as the cycle returns to normal, if it ever does.
Plus the whole investor (foreign and domestic) vs owner occupier discussions we are seeing plenty of...