Humans have a need for a certain kind of emotional high, that in whatever way, people find a source. Some people find it in competition, drugs, sex, music, art, creation, fear, ... there's probably a whole taxonomy in there.
One of the ways people find it is in social displays of moral superiority. People hated this about organized religions and left in droves, and yet here we are with the exact same behavior.
There probably was a very valid evolutionary reason why this is so prevalent in humans, but like most things that make us feel good, uncontrolled they get taken to terrible extremes.
The point is recognizing that this behavior is a need finding a source of stimulation. If you want to fix it you have to find better sources for that feeling and recognize what is happening... and distribute that recognition into the public consciousness.