If a man is going into a bathroom and was being a pervert, it would be very difficult to prove that. It would be impossible to prove that a man looking where he wasn't supposed to was doing so intentionally. Even if he said or did something, it would become a he said she said situation. In contrast, demonstrating that a man went into a woman's bathroom would generally be much easier.
By making it illegal (I don't know if it actually is, but lets assume) we accomplish two things. First, we make deter men from entering the bathroom in the first place, lessening the likelihood that a woman is harassed to begin with. Second, we make it so that in cases where there is a harassment, women have some sort of recourse. Even if they can't prove the actual harassment, they can prove the... I guess we'll call it trespassing.
Whether that actually works or not, that's the theory behind it.
I largely agree with the above logic, but will point out that I have said nothing here about the infamous "bathroom bills" that have been advanced by conservative forces in red states and actually enacted, and only partially, I believe only in North Carolina. Though they are best known for their bathroom privacy-related provisions, they also contain(ed) many other elements, like in one case a provision barring individual communities from passing any new laws advancing the rights of same-sex couples and gay individuals.
To be honest though, I was stunned by the ferocity of the corporate response to North Carolina's "bathroom bill", with whole industries and even the NBA pulling out of the state, essentially imposing voluntary economic sanctions, specifically over the restroom privacy provisions and not anything else. Now you take the response to say this whole raft of states last year passing laws banning abortions altogether, period, with no exceptions even for rape survivors, after just a few weeks of pregnancy, before many women even know they're pregnant. There went out broad calls for similar boycotts of those states, and of Georgia in particular. The response this time? It turned out that it was racist to boycott Georgia because there are lots of black people there whose employment you'd be hurting! And thus it did not materialize. It hadn't been racist to sanction North Carolina, but it apparently was in the case of Georgia. I found it impossible not to notice the contradictory logic...and also the similarities. Similarities, you ask? The key commonality that made both of those contrasting responses possible can be found in that the interests of women were on the losing end in both cases.
Well anyway, like I said before, there are problematic elements in the so-called "bathroom bills" that have been advanced so far that make them challenging for me to support. Moreover, honestly the bathroom privacy issue really is the least of my concerns when it comes to this drive to make everything unisex anyway. It's a very minor issue from my standpoint that boils down mostly to one of convenience and comfort. The much more significant issues that I have with this whole let's-make-everything-unisex movement lie in the quest to "gender-neutralize" things like rape crisis centers, prisons, and transition houses for homeless and battered women and their children, those sorts of things. The women who occupy these sorts of spaces are disproportionately from disadvantaged backgrounds and often among the most vulnerable members of society. We're talking about poor women, newly single moms, indigenous women and women of color, immigrant women, survivors of domestic abuse. These women really do need women-only environments and services for their basic safety and well-being. Most women won't use a rape crisis center or a transition house, for example, if it means that they have to say spend the night with a man, or just someone they perceive as a man (the psychological effect is all the same), they don't know just after experiencing rape! And prisoners have no way out, to state the obvious; to house them with biological males who are there in the first place for sex crimes just...I don't even know how to put my level of contempt for such proposals and policies into words.
Yes, trans people definitely need the same accommodations everyone else does, obviously. But I simply can't help but feel that when it comes to these sorts of settings especially, the creation and federal subsidizing of specialized accommodations designed to the particular needs of trans survivors, trans inmates, etc., would be far better for everyone concerned than making everything unisex.