I talked to someone personally who at some point had committed a series of crimes, and at some point they started doing things that were more and more likely to get them caught; they told me they thought to themselves, "What am I doing?" But they didn't stop, and eventually got caught.
In a different story, a few years ago I dropped my wallet on the sidewalk outside my house, and someone picked it up and tried to use one of the credit cards in it. Then they got in a fight which got them arrested; and the police found my wallet (with my ID and everything) in their possession. Why get in a fight that's going to get you arrested just at the moment when you have stolen property in your pocket?
My take is this: We present to others, and even ourselves, the illusion that there's just one unified "self"; but really inside there are a number of independent motivations within us. In both cases above, I think there was a part of those people who felt guilty and actually did want to be caught and punished.
It's possible there was something similar going on with the guy who shot the CEO: one part of him had managed to plan everything perfectly so that he could get away; but there was a saboteur. It couldn't ahead of time prevent him from doing the shooting, but it could afterwards prevent him from disposing of the evidence and ensure that he got caught.