ok but based on M2 doesn't explain why investment banks suddenly started to fund risky loans
Yes it does. If you're a bank and you're flooded with credit, you have to lend that money to someone. If you have too much to loan at a reasonable interest rate to "safe" investments, then you'll start doling out money to riskier investments in order to seek a higher return. This especially holds true in a bubble economy where even "risky" investments become "safe" due to certain uneconomic circumstances (e.g. constantly rising housing prices making refinancing a breeze).
M2 will grow as there is more money in the economy. As RE prices rose it the asset bubble grew it drives up M2
You got the cause and effect wrong. Growing real estate prices didn't increase M2. Growing M2 increased real estate prices. More money in banks = more loans = higher demand for real estate.
investment banks were not regulated by the Federal Reserve at that time ( to the best of my knowledge)
The financial industry is one of the most regulated industries in the United States and across the world. Moreover, the financial crisis wasn't a problem unique to the American financial industry, but to banks in every developed economy in the world. The one commonality between all of these developed countries is that central banks around the world engaged in a concerted effort to lower interest rates in the early 2000s.
Lehman, Bear Stearns etc.. could never have created and sold these risky loans without having the triple A bond rate or the CDO's (collateralization) or CDS (insurance against default)
Notice that the loans they sold weren't risky because ever rising real estate prices basically guaranteed a return. Even in the case of a bankruptcy, the bank could have taken the real estate and sold it at a profit.
They were only risky with hindsight, when people finally realized that there was a massive bubble that was fueling the whole gig.
AIG was of course a big part of this too as they were selling insurance without having the necessary reserves (which I why they became insolvent in one day as soon as their rating was downgraded which immediately required more reserves which they did not have)
And again, you reverse cause-and-effect. AIG would not have been able to do that if we weren't in a bubble-economy. They would have gone bankrupt looooong before 2008/2009. It is the bubble that fueled risky behavior and not vice versa.
I certainly believe the Fed played a role but I don't think they were the cause
You can believe what you want but logic is not on your side. Even with CDO's, CDS's, and all the other innovative financial instruments, no bubble could have formed. The more people would have bought houses, the higher interest rates would have gone. The higher interest rates, in turn, would have reduced demand for housing. It's as simple as that. But because the Fed follows an interest rate policy, it in effect fueled a bubble.