@GnotherGnu nothing keeps anyone completely safe but we still lock our doors, and we use passports even through burgles can pick locks and terrorists can take passports.
Most males don't want to sexually attach anyone but quite a few males do want to sexually attack women. So isn't it logical to keep males and females apart when they are getting undressed, sleeping etc. Unless they are already a family unit etc.
Plus because men and women are biologically different there is some sense of privacy when you need to go to the loo etc. get changed.
"or likewise with women." You know women don't commit most violent or sexual crimes, don't you.
If we don't care about sex segregation in sport and toilets, changing rooms, etc, why do we have it, why have we had it for decades?