> the first task for the police is to protect innocent civilians
The first task for police is to keep crime reduced. Notice the police don't usually arrive until after a crime has happened. Not to say they won't genuinely do their best to help you, but that isn't their job. Their job is to keep crime down. The only person responsible for your safety and protection is yourself.
> Even if it causes harm to the policemen themselves
A fair bit of cops get killed in the line of duty. A lot more are "lucky" and only get injured - that might mean losing an eye, permanent spinal cord injuries, or just losing a few fingers or toes. Sucks to be the police officer, also sucks to be their family.
Cops deal with the worst of the worst on a daily basis - the rapists, the murderers, the drug dealers - and they have to constantly make life and death decisions. Is that junkie reaching into their pocket to grab their ID or a used needle to stab you with? Would you take a bullet for a serial rapist or a spouse abuser?
It's easy to cast stones. It's a lot harder to be the one driving up to a potential hostage situation where innocent lives may depend on you. Sure, it might be a prank - or it could absolutely be a barricaded suspect with innocent family inside the house with them.