Everyone wants to paint themselves as the hero of the piece. No one wants to be the bad guy, even if they want all the rewards of doing a Bad Thing. Here are a few different ways someone might convince themselves that they are in the Right (even when they're Wrong).
They will justify themselves. They will rationalize away what they have done to make it more in line with acceptable social conventions or their own ideal principles. The story will phrase it so that their actions was either the right thing to do and that any sane person would have done the same ... or at the very least, that it wasn't their fault. Someone else was to blame. The dissonance between their own ideal self and their actual actions might lead them to repeat the tale to anyone who will listen. It might even form an internal monologue if the dissonance is strong enough. The story will often have more details than are necessary because the speaker feels they have to back up their words with fact in case others disagree. There is a greater need to make the tale 'water-tight'. (Of course, the same could be said for someone who whole-heartedly believes in an unpopular topic).
Dr. Matt has a brilliant quote on his web-site: "If you have to try to convince yourself, that means . . . you're not convinced!"
Why accept the blame when you can accuse others of doing you wrong? You don't just need a scapegoat for others to blame. You can invent one for yourself. This is the foundation of "I kill because no one ever loved me" or "if she hadn't dressed like that, I wouldn't have raped her" and plays into the self-justification. This can also work on a more subtle level. A long-winded self-justifying tale of how a co-worker had made his working life a living hell with an oddly succinct statement of how they tricked the Manager into firing her before launching once more into Why the co-worker deserved it.
More a motivation than a justification, excitement is still worth a mention. Some people just get a kick out of other people's misery. Perhaps it's the sudden adrenaline rush from risking reprisals or other consequences. Perhaps its the flush of power - knowing you can do that to someone. Maybe it's just some primal instinct that the bad guy has more than anyone else. Someone like this likely believes that others would do the same if they could - they're either too weak or foolish and thus in their own way deserved it.
Some people just make a point of underestimating how bad their actions really are. They think they're not really hurting anyone really. An excellent example of minimisation would be a classic self-justification from Robin Hobb's Liveship Traders trilogy where a rapist said women should stop whining about how horrible rape is because a woman's capacity to have sex is unlimited and thus they're not really losing anything.
Also, when building your opposition, don't forget that they might be as righteous as the protagonists' allies. This can be especially brutal and effective when actions on both sides are escalating matters and you can understand everyone's motivations. Who's in the wrong? The tribals or the miners? Both are warring to support their own way of life.
Personally, I love when an author surprises me with a villain's motivation. When I sit there, and I can almost understand where they're coming from. When the most atrocious crimes almost seems reasonable and rational given that argument (and ignoring a whole bunch of other facts). It's kinda creepy having that shudder down your spine and going: "Wow, that *almost* makes sense ... but it's still wrong."
Next week I'll do something on the psychology of Shame.