Spite for others can overpower any self interest. If the person has been shaped by past experiences to rely on spiteful actions as a coping mechanism they will struggle to do anything else. The reward centers in their brain respond more to the disadvantage their actions have caused the other party rather than any advantage they create for themselves. Rebecca Kazinka's actually been doing studies on this for a few years now if you want some reading.

I'm certainly not alone in trying to make sense of it all without completely destroying my faith in averaged-out humanity.

A hypothesis: The "spite" is secondary to their insecurity and fear of not belonging to a "safe" group, in a world they assume has vicious and unavoidable hierarchies or cruelty. Having the out-group hurt (or even just baffled) occurs in service of that.

Professing and supporting stupid beliefs is "loyalty", an expensive (and therefore prominent) signal of membership. Like tattooing Dear Leader's name on one's forehead. It's less an opinion one holds and more a song they sing to fit in with the flock.

I find that focus on insecurity and loneliness and fear—versus the reward of belonging—a bit more comprehensible than spite as its own reward.