@1muflon1's answer is correct, but only tells half of the story.
The other half of the story, that Brookings studiously avoids mentioning, because it conflicts with their values, is that lenders were forced to make sub-prime loans by government policy:
during the 1980s and 1990s, powerful activist groups demanded that banks reduce their lending standards, such as reliance on creditworthiness and higher down payments, and organized protests against those that would not, claiming that higher standards disproportionately hurt low-income earners and minorities. For example, in congressional testimony, one community activist, Gale Cincotta, made clear that “lenders will respond to the most conservative standards unless the GSEs are aggressive and convincing in their efforts to expand historically narrow underwriting.”
Under enormous pressure from these groups, the Clinton administration decided to expand federal government servicing of low-income and minority borrowers through various “affordable-housing goals.” Imposed in 1992, the different goals created a quota system requiring a certain percentage of the loans that the GSEs acquired each year to have been made to borrowers in financially isolated communities or those who were at or below the median income in the communities in which they lived.
The enforcement mechanisms had teeth:
Bank regulators began to pressure banks to make subprime loans. Guidelines became mandates as each bank was assigned a letter grade on CRA loans. Banks could not even open ATMs or branches, much less acquire another bank, without a passing grade—and getting a passing grade was no longer about meeting local credit needs. As then-Federal Reserve Chairman Alan Greenspan testified to Congress in 2008, “the early stages of the subprime [mortgage] market... essentially emerged out of the CRA.”
and were continuously expanded until 2008 (Bush continued Clinton's policies in this area, as part of his effort to try to appeal to minorities):
The initial low-to-moderate income quota for Fannie and Freddie was around 30 percent per year, a goal that was not too hard for them to meet. But the LMI goal was continually raised, to 40 percent in 1996, then 50 percent in 2001, and up to 56 percent in 2008. Impressively for a government agency, the GSEs hit their targets—by June 30, 2008, 57 percent of the 55 million mortgages in the financial system were non-traditional, meaning either subprime or otherwise of low quality.
Here are the links to the FREDDIE MAC and FANNIE MAE reports if anyone wants to verify the figures above. They are correct. E.g. for 2007(page 5), Fannie Mae had a goal of 55% of all mortgages being to "Low to moderate Income" and achieved 55.3% and a goal of 25% being "Special Affordable" (defined as "low-income families in low-income areas and very low-income families") and achieved 26.5%.
It's easy to see that if you are forced, by government policy, to write 1/4 of your mortgages to very low income people, usually with very low credit scores and a high likelihood of not being able to pay, the only mortgages you can give them are sub-prime ones. Things like Ninja Loans are not comprehensible without the context that they counted towards a high, mandatory quota.
Note that I'm not implying this was specific to Fannie and Freddie. All lenders were pressured into this sort of lending as described in my second quote, but these 2 accounted for more lending than everyone else combined leading into the crisis and were extremely open about their quotas, so they are the best illustrative example.
The banks tried to make lemons into lemonade and engaged in all the financial skull-duggery described by Brookings, because:
Whatever went on inside the various agencies, financial regulators—whose job it was to enforce safety and soundness regulations—in the end deferred to government affordable-housing goals. Conflicted laws created conflicted regulations and conflicted regulators. Safety and soundness considerations required that regulators step on the brake. Affordable-housing goals required them to step on the gas.
So there were 2 ends of the horseshoe, government mandates and the willingness of the financial system to exploit the resulting tsunami of sub-prime loans that created the crisis.