Maybe you've not been to a night at a comedy club where things all go wrong, but when they do go wrong there can be fights, and even outright attacks.
What starts off as banter that the act perhaps indulges can soon escalate into something much more serious if a come-back is taken as a little too personal, too offensive. You just need someone with a few drinks in them to be humiliated in front of their friends for it all to go wrong.
The staff have seen it all before. They know who is likely to cause trouble, they know what level of response is appropriate to try to stop things from escalating. They know who will shut up if they have a word, they know when they need to ask someone to leave. They know the friend to talk to to try to get their drunk pal to quieten down. They know when to send a signal to play loud music to interrupt the escalating exchange between act and heckler.
To do it well and to maintain safety continuation of the show it does take a lot of experience.