Did you read the SC judgement?
They made allowances for male children. I believe they said ‘under 10 years old’. It was mentioned specifically.
And any male person that has a valid reason to be in there such as a cleaner or maintenance staff will have a sign out so female people can make a choice.
If a set of toilets breaks, again, signage can be used to warn people about it so they can make a choice.
Consent is key here
The scenarios you mention do not mean a law cannot be made. And sure, there will always be exceptions available for exceptional circumstances.