I first heard of it in the book titled - Mistakes were made, but not by me -
Here is the book description:
Why can we see hypocrisy in others but not in ourselves? Are we all liars? Or do we really believe the stories we tell?
..... a compelling look at how the brain is wired for self-justification. When we make mistakes, we must calm the cognitive dissonance that jars our feelings of self-worth. And so we create fictions that absolve us of responsibility, restoring our belief that we are smart, moral, and right—a belief that often keeps us on a course that is dumb, immoral, and wrong.
It was one of those books that was so enlightening that I talked about it ad nauseam. If you are curious about cognitive dissonance, get the book.
In simple words, cognitive dissonance is when we tell ourselves a story/lie so we can deal with something that is happening to us.
After reading about it, I really tried to avoid it. Then it occurred to me that maybe it is an evolutionary defense. Maybe we need cognitive dissonance to go on.
I have developed a new found respect for the evolution of the mind.