It's because people were being offered and accepting loans that were larger than they could actually afford. For example, when my husband and I applied for a loan, we were approved for $500,000. This is a lot more than we could actually afford the payments for! We went with a house that was $200,000, which made for monthly payments of $1100. If we had done, say, $400,000, the monthly payments would have been $2200. If one of us lost our job, it would be really hard to keep making that payment!
The other part is that when interest rates were low, people were getting "interest only" loans. So they were getting $400,000 loans at low rates and only paying the interest (say, $1000/ month). They weren't paying down the mortgage or building up any equity in their homes. But the idea was that they would buy a $400,000 house, pay the interest only for awhile, and sell it for $500,000.
However, then the market started getting glutted- that is, filled with a bunch of homes. More homes were for sale or being built than there were people looking to buy them. Home prices started going down, interest rates starting going up. When those people with interest only loans (who could afford $400K homes at $1k/ month payments) suddenly found their payments jumping. So they really couldn't afford that house anymore (especially considering some of these people were investors who own a lot of houses). They fell behind on their payments. If you fall behind long enough, the bank will foreclose.
It's more complicated than that, but there's a good overview for you. You'll be seeing a lot more of this in the future, by the way. It's probably going to get pretty bad.