Trolls are just bullies, I guess. For some of them, getting a rise out of people strikes then as funny, probably because of superiority issues. The psychology is interesting, but those people likely aren't leading very happy lives. Karma probably isn't top of their priority beyond it being funny how many people have gotten a rise.
There's also toxic people who hang around with trolls and other toxic people. They form social groups where some minority group becomes the butt of a joke, which then becomes an "in joke". This historically has been against lgbt folks, certain nationalities, furries, disabled people and neurodivergent people, among others.
Then those people internalise those feelings, and spread them to other social groups, where they either land or the person gets confused as to why people hate them. If you run a community, you need to keep an eye out for this sort of thing and stop it before it takes hold.
Trolls attack people to get a reaction. Toxic people attack people out of indifference to their feelings.
There's also a group of people that feel they have a moral imperative to help people. That is, they should actively spread their own moral views and opinions so that other people may learn from them. This may or may not be a problem depending on the views of you and the platform.
Anyway, that's just me rambling a bit, sorry if it's all nonsense.