Cognitive dissonance is a theory from social psychology. Originally coined by Leon Festinger in 1957, it describes a phenomenon whereby people's actions are in discordance with their beliefs and values, or vice versa. For example, someone may know smoking is bad but they smoke anyway. This leads to uncomfortable feelings of unease, guilt, frustration or shame.
Cognitive dissonance naturally results in an attempt to bring behaviour and cognition in sync again, by changing either behaviour or beliefs (i.e. finding a way to justify the behaviour in one's own mind). Confirmation bias is often a way to avoid cognitive dissonance - people naturally gravitate towards information that confirms what they already believe to be true to avoid the discomfort of having to reassess their behaviour based on new information.