Sometimes the rules from number 2 should be given priority over law. In that case the right thing to do is to break/not follow the law.
Here's where the problems with that lie:
The police are there to enforce rules other people made. Not rules they made. If an individual police officer decides to enforce a law they made up, or decides to forgo enforcing a law they disagree with, then big problems can arise.
Imagine a police officer who's racist. In their mind, the "right" thing to do is something along the lines of what the KKK advocates. So, when they come across a hate crime, they might ignore it with the excuse of "I'm doing the right thing, not what the law says" and under your logic they'd be entirely justified.
Now you could argue objective morality to counter that, but the fact of reality is everyone has their own system of morality. There is no authority to decide what is truly "right and wrong," so there would be no way to objectively determine whether a police officer breaking the law for moral reasons would be justified or not. If we're going by popular vote about morality, that's what the laws are ideally
supposed to already represent. We already tried going by what God says, and I dearly hope you're not advocating yourself or any other individual person to be the absolute authority on morality, so...
A police officer should follow the law to the letter. If the law is corrupt, then it needs to be changed (and said officer has just as much power to change it as you do).