I would enjoy living in a world where these sort of documents are not necessary. However, people are absolutely discriminated against in open source projects and these documents aim to alleviate some of those pains. This sort of rule is necessary as an unregulated expectation of kindness isn't working (eg "be excellent to each other").
The prospect of anonymity could help, but cannot be expected. People shouldn't have to hide who they are as a person in order to contribute.
People also make a weird claim that people are more offended by things and I don't see how that's a bad thing. I would prefer society that calls out these intolerances instead of them just dealing with it. If gay people "just dealt with" the adversities they faced then we'd still be persecuting them. Part of "being offended" is being vocal about people doing and saying terrible things in order to put societal pressure on them to change.
There are some legitimate concerns around CoC's and the like, but the people protesting them aren't attempting to help solve those issues, they're doing so to get rid of these rules and maintain the status quo.
Hope this at least exposes some people on the fence to some of the reasons people support CoCs. I can't speak for every socially liberal person but I'll happily engage in some back-and-forth if you disagree with any points I made or just want more information.