Anonymity is part of it, but I think an understated part is just lack of community. The people are just names on a screen and it’s easy to lose sight of the fact that they’re people.
The interface of reddit and HN kind of encourage this. Old PHP BBs used to have avatar pics and signature blocks and stuff that distinguished your post as yours. It sort of anchored your “content” to an identity, so over time a community develops and people start to develop reputations and stuff. That doesn’t happen as much when everything is visually indistinct from everything else.