I'm not sure your right regarding the UK(?).
My - possibly mistaken - understanding is that if a sports governing body does not consider it to be necessary for fair competition or for the safety of competitors, then they can permit transwomen (ie men) to compete in women only sports.
Up to about 5 years ago it was quite common to see stories of mediocre sportsmen excelling in women's sport.
In the last few years or so sports governing bodies like World Athletics, World Swimming, the UCI, and the RFU have seen the light and declared that males who have gone through puberty are not eligible to compete in women's events.
My understanding is that they've done that because of mounting scientific evidence and mounting public opininon that allowing men to compete in women's events is both unfair and dangerous. [But see Note below]
They haven't done it because of anything the UK government or UK courts have done. If anything the UK government has been complicit in allowing men to compete against women.
It's just like shops selling clothes are not obliged to have single sex changing rooms if they don't want to offer them - although that might be indirect sex discrimination against women
[Note - even then this seems only to appliy to "elite" sport and not necessarily recreational sport]