False dichotomy fallacy.
No cop is invulnerable to the effects of breaking the law.
Police in general are trained to de-escalate a situation, not to go around shooting people.
But if someone attacks or threatens a cop, they will likely be shot. The cop has the inherent right of self defense, same as anyone, WITH THE ADDITIONAL concern for keeping such threat for harming the public. They will empty the magazine into the threat, if it comes to that.
And the courts and the public will back them up on it.
BUT,
If a cop goes rogue and starts attacking the innocent, that cop is breaking the law, and the defender has AGAIN the inherent right to defend himself, including emptying his magazine into the rogue cop.
And the other police, the courts, and the general public will back them up on it.
Yes...cops are subject to following the same laws as any citizen. They are NOT immune if they break the law!