I am so sorry to hear that, Bella. That must have been extremely disturbing and frightening.
As others have said, I think it is down to the gym to now review their safety policies and how they handled the situation. It sounds like they had done their best in previously banning him, and the fact that he burst in meant no one knew how to handle it.
Calling the police was certainly a good response. Even if someone has a mental illness, if their behaviour is threatening harm or danger to others, that should still be dealt with accordingly.
I think trying to remain as inconspicuous as you could and not make any effort to engage or confront him was the best plan.
This might sound strange, but he was potentially less likely to attack a female person than a male, so having only female staff present may have actually helped to bring about those periods where he temporarily calmed down. However it’s extremely hard to predict, with any one individual, what will fire things up more or deescalate things. However, in general as human beings, when we are angry, confrontation tends to escalate things.
Again I am so sorry to hear that this happened. I hope the gym can learn from what happened, and I hope the man in question will be able to access suitable help.