The market did not create the housing crisis. The government fiddled with the market all to hell, with the Community Reinvestment Act, the regulations surrounding the ratings agencies, Fannie Mae and Freddie Mac's unmarket-like backings of loans, and a hodge-podge of other lesser interventions.

When the market was allowed to make decisions about who should get loans, the standards were a lot higher. But it wasn't "right" for people to have to put 20% down and have a very solid credit rating, because it discriminated against poor people (and Democratic voters), so the government fiddled until it produced the result it (thought it) wanted, forcing banks to lower mortgage standards until we eventually worked our way down to no-money down ARMs.

(BTW, the claim the government had nothing to do with it is to claim that all the regulation like the CRA and Fannie Mae and anti-discrimination all had absolutely no effect at all, in which one must answer the question, if regulations like that are so ineffectual that you can't lay any responsibility for the current crisis at their feet, then why do you think government regulations are the answer to anything? Either they are effective or they are not, but you can't flip back and forth depending on whether you like the effect or not.)

The problem is that people think of "the market" as a fundamental property, but in fact it is a derived property. The reason why the market tended to correctly allocate mortgages prior to the government's heavy-handed decades-long intervention is the incentive structure. Always look at the incentive structure. If my bank is going to issue me a mortgage, and the government leaves them alone, they are going to take a lot of steps to protect themselves, such as setting the requirements for your credit strength very high, and requiring large downpayments, and generally ensuring they aren't going to be left holding the bag when the mortgage falls through. Alternatively, if they're going to sell that risk, the receiving party is going to want the same due diligence. The government interventions basically systematically tore than incentive structure apart, by allowing them to just dump the mortgage off on Fannie Mae/Freddie Mac, by requiring them to make loans that they basically knew would fail but the government held guns to their head to do it, etc. If I had to pick one thing that really enabled the housing crisis, it was the ability to dump mortgages off on the FMs for what were in actuality above-market rates, then for the seller to be free-and-clear of the responsibilities. Other things may have accelerated it, but that structure guaranteed disaster on its own.

No, the market isn't "always right", but that's not really the question. Nothing is "always right". The question, which is more likely to be right, the market system or the government system? One of the big reasons I tend libertarian is that I empirically observe that the government almost inevitably creates incredibly broken incentive structures where the market tends to create ones that are much more connected to reality. In this particular case, the "reality" that the market is much more connected to is the question of "will X be able to pay their mortgage back?" I have to use the broad term "reality" when discussing it in general, but it actually comes back down to specifics like this.

One much also distinguish between "the market" being broken, and reality being "broken". Yes, mortgage requirements were quite high; that's because in reality it's a huge risk. It turns out the market wasn't broken here, and the efforts to "fix" it were the true brokenness.