People are of course taught morality and ethics while growing up. Even those with a horrible childhood are taught horrible ethics, often by example.
Each person can choose whether to accept or reject their upbringing.
A very large number of those with horrible childhoods become good people as adults.
A much smaller, thankfully, number of those with good upbringings choose to behave monstrously.
I'm listening to a book right now on the Leopold and Loeb case. Both had a perfectly normal, indeed highly privileged, upbringing. They chose to turn to evil, out of boredom and a highly mistaken superiority complex.
On re-reading my comments above, I realize I've been too dogmatic. Some people really are insane, others choose to do evil for a variety of reasons, and some are perhaps a combination. Very hard to tell which.
The only time a person can make a choice is when he has a friend or relative or fellow citizens that tries to set him straight and gives him the opportunity to make a choice.
When a person is surrounded by a monolithic culture, where everyone tells him what he already thinks, then he has no choice to make.
At that point, the only thing stopping him from doing bad things is the punishment that the society at large will hit him with if he does it.
If he no longer fears that punishment, or think the whole society at large is a farce in the first place, just thing to be toyed with and destroyed, then there is nothing to restrain him.