Back in the days when everyone knew what single sex meant, it was easy. You divided by sex, in wards or bays within wards, and used side rooms or mixed bays occasionally, and temporarily, when demand exceeded supply. Always with appropriate apologies and explanations.
I am something of a dinosaur with nearly 40 years of healthcare experience. Once upon a time, it was also normal to run each ward with 1 or 2 empty beds most of the time so that there was extra capacity when required.
The Thatcher government decided that was inefficient and closed a lot of beds. Mixed sex wards became common as hospitals started to struggle with capacity. Then in the inevitable backlash, single sex wards were introduced again. Except that as we all know, they actually weren’t.
Looking back, I want to say the reasons policies went with gender and not sex, were out of kindness, naivety and misguided attempts at inclusion. But reflecting now on conversations and directives about not telling parents about their children’s gender preferences, because they might be bigoted, it’s hard not to reach the conclusion that the people who were the real safeguarding risks, weren’t simply a long way ahead.
But to answer the point in the OP, it’s a problem of both political will and lack of bed capacity.