I think it’s doing both but not equally.
The internet is great at helping people find weird little niche communities they’d never find in real life (for example this reddit group). That part is genuinely good! You can be into some extremely specific thing and suddenly find 100 other people who care about it too.
But the big platforms (twitter, YouTube, instagram, etc) don’t really reward that kind of small, specific community anymore. They reward scale, reach, engagement, and stuff that gets an instant reaction. Overtime the subtle differences between people get flattened at scale. Instead of lots of strange little human-sized groups, you end up with bigger identity buckets.
Maybe that happens naturally whenever groups get large but social media definitely seems to speed it up. It doesn’t just connect or divide people, it changes the way groups form in the first place.