From a writer's point of view of creating a character, I believe that we need to look inward. All the emotions that will drive the average, sane person to do something unexpected are all there inside us. Given the right impetus, a person will do the unexpected.
I don't believe a good person with a strong moral center will deliberately do something evil like cold-blooded murder, for example, but a good person will kill in the right circumstances.
From my own experience, I know I'd kill in the right situation. I was sixteen, my dad was camping with the Scouts, and someone woke me by trying to come through my bedroom window in the middle of the night. I had a loaded pistol, and I'm an excellent shot.
I knew I could shoot through the window, or I could get the gun and run to the phone on the other end of our big house. Either way, I'd be safe. But my mom and my kid sister were asleep in other bedrooms, and I'd be leaving them to the burglar's mercy if I ran.
In that moment of decision, and with cold, certain clarity, I realized I was perfectly capable of shooting the burglar to protect my family. I also realized that he'd have to come through the window before I shot so I would know he was down, or he could come through another window anywhere in the house.
I knew if I told him to stop, he'd keep coming because I'm female and so small he'd probably think I was nine or ten, and I'd have less of a chance of killing a moving target with a small caliber gun. I knelt behind the bed with the gun in my hand and waited for him to come through the window. I planned to put three shots in his heart and save three shots for just in case.
Fortunately, the dogs scared him away before he made it through the window, but I'll never forget that moment of cold certainty, and I know that I would do the same now.
As a writer, I've used that moment to help define my good characters who are driven to the edge with hard choices.
The trick as a writer is to make the reader believe that a character will do something outside of their experience. If I were writing that personal experience as part of a novel, I'd have already shown the reader that this character loves their family, and that they have a gun and the experience to use it.
When that moment of decision comes, the reader wouldn't be completely surprised that the character chooses to stay rather than fleeing like a self-centered bunny.
If a writer doesn't make you believe a character will react in a certain way, she has screwed up badly.