There is a general understanding that police officers deserve implicit respect while on duty, more so than random citizens, as they are representatives of the law. Swearing at a random passerby is rude but legal, swearing at a police officer is against this need for respect and is a misdemeanor in many places around the world.
Police do need authority and respect in order to do their jobs, of course. But at the same time their position of power and their role as maintainers of public peace mean they should have a thicker skin rather than thinner. They should be able to keep their professionalism and composure in the face of adversity better than the average person, and someone being verbally disrespectful towards them is at the lower end of that.
Police officers who think their pride needs to be put first in the name of authority may be common around the world but that doesn't mean reactive cops are a good thing.
It's perfectly legal in the US. In fact it's legal to lean out your window and yell at them. It's protected speech here, and for good reason. Otherwise the cops could just say your speech made them feel disrespected and you could get penalized. The first amendment in the US has been interpreted pretty broadly to protect a lot of speech that in other countries could get you fines or jailtime.
Respect has to be earned. They have done the opposite.