It shouldn't surprise you that online communities are a reflection of human nature. The behaviors we see are the effects of groupthink taken to its extreme. Even in "civilized" forums such as this one, you'll notice people conforming with the group mentality, and deleting their posts if they get downvoted. When there is little to no moderation, and viciousness is acceptable within the group, this behavior will spiral out of control, as individuals try to one-up each other, leading to vigilantism, manufactured outrage, cancel culture, racism, and all sort of abhorrent behavior an individual wouldn't do in isolation. We all seek validation in our ideas, after all.
All of this still exists offline, BTW. This is how riots happen. What the internet does is make it more possible by connecting more people than we traditionally could communicate with, and providing a safe space for any kind of discussion to happen. It's a tool our tribal monkey brains aren't ready for.