The biggest bailout was AIG who’s an insurance company. They sold the most credit-default swaps on the MBS. They were on the hook for billions and billions in insurance payouts when the defaults started. Most of the AIG bailout went to payoff hedge funds who owned the CDS contracts.
If you want to trace back the start of subprime, it was initiatives under Clinton that created it. It was the mindset that credit scores were discriminatory and everyone had the right to own a home. They bullied banks into underwriting stuff they didn’t want. To get them to do it the government agreed to use Freddie/Fannie to buy the mortgages and take them off the banks’ books. That’s why Fannie/Freddie failed so spectacularly.
The banks only failed because the MBS they owned were suddenly worthless due to lack of liquidity in the market. They had to mark-to-market the MBS down to near zero which ruined their financial reserve ratios. They needed to urgently raise cash in a panic and couldn’t. Mark-to-market is horrible is there’s a panic. It just throws gas on the fire. It’d be far smarter to use accounting similar to warranty reserves where you adjust for future expected losses. You increase that as defaults increase, so the MBS lose some value but not 90% over night.
You can blame the banks, but they were only doing what the government forced them to do. The banks all knew it was a horrible idea which is why they didn’t want the mortgages on their books.