Regarding private spaces where people are normally disrobed, partially or fully, but more so than they would normally be in a public space.
The primary consideration is privacy rights. People tend to want control over who sees them naked, or who sees them in minimal clothing or in clothing that is normally not meant to be seen. (Do I have to spell this out? Just in case, yes. Women don't normally walk around with just a pair of panties covering up their private parts.) This is particularly true if the observers are of the opposite sex. Being exposed, especially to the opposite sex, creates anxiety. (Obvious exceptions apply, but people want to be very careful about when to use those exceptions, and with whom.) This feeling of anxiety is generally more severe among women.
This feeling associated with being unclothed, especially in the presence of men, is sometimes termed "modesty", and it is a deeply rooted psychological reaction. I do not believe that it is fully created by society. I believe it is rooted in instinctual behavior. It is shaped, molded, and intensified by society, but I believe it is a natural phenomenon deeply rooted in the human psyche, related to ways in which sexual signaling is performed by human beings.
Part of this, but not all of it, is related to a legitimate fear of sexual assault. Men are generally bigger and stronger, and capable of rape. From time immemorial, rape actually happens to women. Once again, I believe this fear is not something created by society, nor is it an objectively rational evaluation of actual risk. There is an instinctive fear created by disrobing in the presence of someone who is capable of rape. That fear can be controlled, modified, or intensified by societal pressure or by conscious effort on the part of the person affected, but it perfectly normal and understandable. If a woman feels anxiety disrobing in the presence of a man, this is not a failure on her part. It is perfectly normal, and it is actually wise of women to pay attention to that anxiety, and not try and minimize it, because the threat of rape is very real, and women ought to be aware of that possibility at all times where it exists.
Note that I am talking about anxiety related to the fear of assault, and I am saying that this anxiety is natural, and should not be dismissed, even in cases where some sort of measures make assault extremely unlikely. For example, it seems almost impossible to think that a single, unarmed, young man, would rape a woman in a high school locker room when several young women are present and observing. Even in that situation though, a women would naturally feel uneasy disrobing in the presence of the man, and those feelings should not be dismissed or ignored.
To protect women both from a legitimate risk of rape, or from the anxiety that has its roots in a fear of assault, even if the actual risk is minimal in the specific circumstances present, areas where people are disrobed are segregated so that the disrobed women are only observed by other women.
If a male is allowed into those spaces, he will be perceived as a man, and those anxieties will be triggered. It does not matter what the internal state of mind of the male is. It is his presence as a male that causes the anxiety. If the person is bigger and stronger than the woman, and has the sexual equipment necessary to penetrate and/or impregnate a woman, then all of the elements are present to create a reasonable fear of disrobing in the presence of that male. Therefore, segregation by "gender" is inadequate to protect women. To the extent that the vulnerability to actual assault exists in those places, it can be perpetrated by a transwomen as easily as by a man. Likewise, even if the actual risk of assault is minimized by whatever means available, the associated anxiety is still triggered, just as if an "actual" man were present.
In other words, all arguments for excluding men from female spaces apply equally to trans-women.
Fear of sexual assault, whether an instinctive fear or an objective assessment of risk is not the only element involved in the desire to avoid disrobing in the presence of the opposite sex. Other elements involved are an anxiety about body judgement, and presence of concerns about attempts to engage people in erotic activity, i.e. flirting, being "hit on", or being "checked out". In the interests of brevity, I won't elaborate on those at this time. I'll just reserve comments until later. These issues can affect both men and women, but differently.
Finally, it may also be said that the transwoman may experience anxiety if required to use all male facilities. This can be avoided by providing a separate facility that can be accessed by the small number of transpeople who use those facilities. That solution is often rejected on the grounds that it is somehow unfair to treat transwomen differently than cis-women. In the interests of the reader's time, I won't give a lengthy argument about that at this time, but I will be succinct to the point of bluntness. I don't care. I care about safety, privacy, and access to facilities, but that's about the limit of my interests. If desired, I can elaborate and explain why, logically, I don't think I ought to care, but I will leave that for another time.
Also, I will be brief in commenting about sport. Sports have two important functions in society, which are entertainment and inspiration. People enjoy watching them, and they serve to promote healthy athleticism among spectators and competitors. In order to best fulfill those functions, the competitions must be among the best, most athletic, participants. A highly athletic well conditioned and well trained woman will generally lose to a much less athletic male. The presence of transwomen in women's sports means that the participants are not the most athletic or healthy competitors possible, and thus detract from enjoyment and inspirational value of both spectators and participants.