At my gym I took a beginner's class (which is free) and I got told to hold in my pee. I got so desperate I could barely concentrate, i wasnt even aware of where my barefeet were... then I ended up peeing myself in my mum's car from desperation.
If you are in the UK I have no idea what they are telling you to do or why.
Here you are not allowed to go barefoot so I don't know why you had barefeet. I don't know what type gym you were in unless you are talking about martial arts.
I would suggest that you use the bathroom prior to class. And I suggest that if you are in a class without your parent you are old enough to make the decision on your own if you can wait or if you must go to use the bathroom. If you need to go you quietly leave do not disrupt the class and come back quietly and resume. If you can't make that decision on your own then maybe you shouldnt be left alone and you should drop out of class.
I also question exactly why this wasn't discussed with your mother and why she didn't discuss this with the gym since asking us achieves nothing.
I think you left out a lot of information and that it had to do with class disruption and focus on the exercise.