Can you explain the EU law? If a man applied to be a girl's PE teacher that would be in a locker room, is that allowed? Certainly not, right? The US allows discrimination in general as long as it's not based on membership in certain groups, unless such membership is germaine to the job. So you could limit gender in my PE teacher example, but you can't for a crossing guard (because presumably, anyone can be a crossing guard but sex matters for PE teaching).
Used PE teaching because I can't think of a better example.