I have IBS too and have had since my teenage years.
I have always been paranoid about being anywhere without easy access to toilets. It can come on at any time and doesn't adhere to a set timetable.
As for periods, I have always been on the heavy side, even as a teenager. I'm 52 now. They are still going and I often flood through any sanpro and down my legs.
Access to toilet facilities is a very basic need. Not all of us can completely control when we urgently need to go.
I do get that there is piss taking in schools, and that sometimes troublemakers can gather in the toilets causing issues. I get that this makes teachers' lives more difficult. I don't really know what the real solution is, but I am against locking toilets and denying access to those who need it.
The minority should not be allowed to make life miserable or uncomfortable for the majority.