How to stop this from happening again in two words
No bailouts
There are at least three parts to this.
This first is do not bailout subprime borrowers by forcing the banks to loan money to them.
The second step is if the banks fail, let them go out of business. This is politically easy.
The third step is to eliminate FDIC insurance. FDIC insurance is the cornerstone of why the con game continues and will probably continue for a long time. A lot of people can see that the subprime crowd had no business getting a loan. And "no bailouts for the banks" is perhaps the only thing Occupy Wall Street and Tea Party can agree on.
But when you tell somebody that there is a chance they can lose $250,000 in their bank account...well...my experiences is about 98% of people don't want that. They don't want the subprime crowd bailed out and the banks bailed out. But THEY want a bailout!
But why SHOULD they get bailed out? They lent money to a business that failed. It is the same concept as a corporate bond.
The solution is to have two different banks. A corporate bond bank and a safety deposit bank. Lending money to the corporate bond banks would be like buying a corporate bond. You lend money for 1 month, 3 months, 6 months, 1 year, 10 years, 30 years. This will allow the bank to have definite payback times which will allow them to perform better Asset Liability Management (ALM). Right now banks offer daily liquidity but they loan out money for 30 years. This is called fractional reserve banking. If everybody wanted their money back at the same time, every bank in the world would go under. This is called a "bank run" and typically happens during a recession when depositors are concerned about borrowers not being able to pay the bank back. Having well defined payback periods greatly reduces this problem. If the bank has some bad loans, too bad for the depositor-they lose.
The other bank is simply like a safety deposit box. They will basically charge certain amounts for safety and check writing services, etc. They cannot lend out money.
At the end of the day, most people won't like these suggestions. Why? Because in a corporate bond bank, they can lose their money. And in the safety deposit bank they actually have to PAY the bank instead of receiving interest.
In summary, the overwhelming majority of people are no different than the subprime borrowers and the banks. Everybody wants to be bailed out. So the game continues and the debt increases. The end game is in 10 years when the baby boomers retire en masse, taxes will be raised and the Fed will print more money which will cause inflation and everybody's standard of living will go down.
Bottom line is don't complain about the banks getting bailed out unless you are willing to end FDIC.