There's theories about it, one of the most prominant is that the path of criminality is the product of failed informal systems. Our informal systems are our families, our schools, our neighbourhoods, etc. There's a distinct trend, or stereotype, if you will, of the average neighbourhood offender who is the product of a broken home, has parents or other immediate family with drug and alcohol dependencies, an all too familiar relationship with the court system, juvenile justice, the equivilent department of family and community services, little or inadequate schooling, perhaps even to the point of intellectual handicap, lack of stability, lack of financial security, the list goes on. There's a whole slew of others, such as white collar and corporate criminals who's backgrounds trends are as varied as the crimes themselves. However, with this garden variety murderer, there's a lifetime of failed systems which build us to be conscientious and generally law abiding. Of course having money or security is no guarantee, but it makes a big difference. Alternatively, not having those things does not mean you are doomed to fail. We do, however, learn from what we see and live with. It is a long process which gets you from being born equal to everyone else, to sitting in the dock of a cold and clinical courtroom where the laws are not going to look at you personally a great deal - as anitram alluded to earlier when she described the disconnect with the crime itself.
As ot how we can actually stop people murdering, there is no one way. Execution is certainly no solution, nor successful method of promoting prevention. Regarldess of what action anyone takes to work on preventative measures, the facts on capital punishment remain. The crimes and the existence of them do nothing to change what capital punishment is.