The theory of cognitive dissonance proposes that people are averse to inconsistencies within their own minds. It offers one explanation for why people sometimes make an effort to adjust their thinking when their own thoughts, words, or behaviors seem to clash with each other.
When one learns new information that challenges a deeply held belief, for example, or acts in a way that seems to undercut a favorable self-image, that person may feel motivated to somehow resolve the negative feeling that results—to restore cognitive consonance. Though a person may not always resolve cognitive dissonance, the response to it may range from ignoring the source of it to changing one’s beliefs or behavior to eliminate the conflict.
https://www.psychologytoday.com/us/basics/cognitive-dissonance