Why do people try to “justify” their behavior?

I’m always amazed at what lengths some people go, to “justify” their behavior even though they know deep down inside that it was wrong or questionable at best. Why? Do they really think that what they did was o.k. or appropriate? People are trying to “get away” with something by rationalizing why they made that…