This really is more difficult than it seems, from a teacher's point of view. Most schools have a "not during lessons" rule because otherwise the disruption can be huge. These are teenagers - they are going to push boundaries, they would often rather be anywhere other than in lessons, and giving them a get out of jail free card can create a nightmare.
From a safeguarding point of view, the corridors and outdoor areas aren't supervised during lessons, because students aren't meant to be wandering about. So if you let everyone go to the toilet during lessons you get increased behaviour incidents. These could be serious, bullying and physical assault, or even sexual assaults considering how frighteningly widespread these are in schools. At the bottom of the scale you've just got kids being idiots and pulling faces or swearing through the windows of classrooms as they walk past. There's no way schools have the staffing capacity to have staff deployed to supervise the corridors & wider site during lesson time, so if you let kids out of your room mid lesson you are necessarily letting them out into an unsupervised environment.
Then you have just the basic swinging the lead, wanting a break from lessons. If you say girls can always leave to go to the toilet then there will be a decent proportion of girls who will just shout "period!" at you and demand to be let out of the lesson, every lesson.
Then you have the use of toilet breaks as a coordinated attack on the lesson. Multiple students all wanting to go, one after the other after the other, just to bugger up the lesson (and everyone else's learning) for a laugh.
The classroom teacher is going to have management coming down on them like a ton of bricks if they are letting kids out of their lessons all the time. But how do you do it for some but not others? How do you let the nice well behaved girls out to go to the loo because you know they won't piss about and aren't likely to be lying, but then tell the disruptive girl who hates your lesson and has arranged with her mate in the other class to both go to the loo at half past, that she can't go?