While we may never fully understand their motivations for this reckless (and questionably legal) behavior, there are a few things to consider that might make it a bit more explicable.
The first is that most of these losses in property value are in the form of externalities; that is, they are costs that are shared among many people, not concentrated particularly on the banks that made the decisions. (This is all the more true because of the fact that we bailed out a number of banks using government funds.)
The second is that mortgages have private mortgage insurance, which compensates banks for some of the lost value if banks foreclose a property and end up having to sell it for less than they paid for it.
The combination of these two factors creates what we call moral hazard, in which the people making the decisions about the risk---the banks---and the people bearing the costs of the risk---homeowners and the government---are not the same, and thus there is an incentive to take on too much risk, which is precisely what banks did before and during the crisis.
When a bank signs a foreclosure, they get all the money from foreclosing those homes, plus whatever their insurance pays; but they only bear a small part of the loss in property values. As a result, they are incentivized to foreclose as much as they can, which is most likely why they engaged in robo-signing.