Because you can bring a case for sex discrimination, or for discrimination on the basis of gender identity. Depending on the circumstances.
Edited to add that if anyone wants to know more about this feel free to ask elsewhere and tag me and I'll try to answer, though I'm not terribly knowledgeable and just having to learn about all this recently. But I can share what I know, if anyone is sincere in saying they are genuinely interested.
As far as I'm aware though, it's just that sex and gender identity are different protected characteristics, as I believe is the case in the UK.