You make a good point about the original reason for separating by sex.
Is that universal, or a convention of western society?
As other people have already pointed out, some societies abandon/kill their newborn babies based on their sex (girls). They are separated by sex.
Here is an article about 'toilet injustice' in India that explains what happens when people, but women in particular, do not have access to toilets www.nytimes.com/2012/06/15/world/asia/in-mumbai-a-campaign-against-restroom-injustice.html?module=inline
Here is a quote from the article: Like men, women in villages often must urinate outdoors, in fields. But unlike them, they sometimes endure taunting and even sexual assault. Many rural women relieve themselves in small groups, before dawn, to protect against harassment.
People here don't seem to have an issue with separating by sex.
It is such an issue, that a film was made about it www.nytimes.com/2017/09/03/world/asia/india-toilet-movie.html
Quotes from the article: “This is a real problem,” said Jagmati Sangwan, a women’s rights advocate. “So many women, especially landless women, face a lot of violence when they go to the bathroom outside.”
To avoid being leered at during the day, some women hold on for hours for darkness to fall. Waiting that long can create health problems, particularly for pregnant women, who are highly susceptible to urinary tract infections, experts say.
The men who are assaulting urinating/defecating/menstruating women are separating out their targets based upon their sex.
Women in cultures/countries that do not have good records of protecting women do not leave their homes unaccompanied. They have chaperones. They do not have freedom or autonomy because they cannot be guaranteed safety from men. So they are separated based upon their sex.
In this country, it used to be customary for women to have chaperones and be accompanied when out and about because of the risk of assault that men posed or because of societal expectations of women based upon their biology. No one queried gender identify. Women and men were treated differently, ergo separated, based upon sex.
We separate by sex to prevent women from being sexually assaulted by men. Or rather, female bodied people from being sexually assaulted by male bodied people. On the occasions I've been sexually assaulted, none of the men stopped to ask my gender identify. They assaulted me because I am a woman and they recognised that. It was my biological sex that mattered.
Some cultures (not Western ones) separate menstruating women from the rest of society so that men don't have to deal with female biology. They are separated by sex.
As someone else said, Boko Harem didn't ask the female children how they identified. They separated the children they abducted from those they didn't by sex.
Are you seeing it yet?