This precisely.
Think back to your interactions with others (siblings, playmates, etc.) as a kid. Those experiences taught you how to interact with others. Obviously there were mistakes - you learn to not punch others, call names, etc. The punishment was often a simple timeout, note to parents, etc.
People need to "learn" how to interact with "others" in a professional setting. This process of learning involves making mistakes. Unfortunately, in the professional workplace, the "punishment" usually involves HR, lawyers, and a risk to ruin one's career/reputation.
So most people prefer to not "learn", and instead stick to interacting with only those they are already comfortable with - e.g. people of the same gender, color, social class etc. Social media has already made this hell. More laws will only make this worse. Of course, this isn't helped by the fact that there are actual assholes who deliberately abuse others.
Anecdote - I once sent a stern/corrective email to a female colleague/junior. There was nothing gender specific in the message. My/our boss was in cc. She forwarded the mail to HR, and I got a rebuke from the boss (male) and an informal warning to not critique women. Voila.