These situations are always going to exist and there is no silver bullet for resolving them. You're dealing with:
1) Human nature - when you're assaulted and humiliated, your instinct to retaliate kicks in. Spit on a cop...don't think he won't respond in kind.
2) Mental health - some of the people cops deal with have mental illnesses so they will behave in ways that are not normal - like not following simple commands to stop resisting arrest. Sometimes restraint is needed for but this is not an easy call all the time.
3) Punching Bag - we don't want to go back to the old days when cops could brutalize people without accountability, but we don't want them to be seen as punching bags either, because people will use them as punching bags if they know they can get away with it
These incidents are dynamic and fluid, and dangerous. Cops have to protect the public and themselves against criminals.
That said, the punches were unnecessary, but understandable.