In addition to self-righteous and opportunism, for many it seems to be a very mundane case of psychological coping.
I’m always amazed at the depth, intricacy and durability of the worldviews people adopt just so they can tell themselves a pleasant narrative about some unpleasant reality.