This is controlled by state law (there is also a federal murder statutes but the federal government doesn't dictate defenses for state law). Here is Washington's. RCW 9A.16.020 says when use of force is lawful, and there are different "public officer" vs. "person" related provisions. Generally, public officers may use force
(1) Whenever necessarily used by a public officer in the performance
of a legal duty, or a person assisting the officer and acting under
the officer's direction;
but persons (other than those assisting an officer) may only use force
(3) Whenever used by a party about to be injured, or by another
lawfully aiding him or her, in preventing or attempting to prevent an
offense against his or her person, or a malicious trespass, or other
malicious interference with real or personal property lawfully in his
or her possession, in case the force is not more than is necessary;
Additionally, RCW 9A.16.040 is a long section specifically about officers, the most germane parts of which are that use of deadly force is justifiable
(a) When a public officer applies deadly force in obedience to the
judgment of a competent court; or (b) When necessarily used by a peace
officer meeting the good faith standard of this section to overcome
actual resistance to the execution of the legal process, mandate, or
order of a court or officer, or in the discharge of a legal duty; or
(c) When necessarily used by a peace officer meeting the good faith
standard of this section or person acting under the officer's command
and in the officer's aid: (i) To arrest or apprehend a person who the
officer reasonably believes has committed, has attempted to commit, is
committing, or is attempting to commit a felony;
RCW 9A.16.050 has more limited circumstances when homicide is justifiable by others (not in self-defense):
(1) In the lawful defense of the slayer, or his or her husband, wife,
parent, child, brother, or sister, or of any other person in his or
her presence or company, when there is reasonable ground to apprehend
a design on the part of the person slain to commit a felony or to do
some great personal injury to the slayer or to any such person, and
there is imminent danger of such design being accomplished; or (2) In
the actual resistance of an attempt to commit a felony upon the
slayer, in his or her presence, or upon or in a dwelling, or other
place of abode, in which he or she is
In other words, the box for police officers is bigger: they can use deadly force to do their job, your plumber cannot.
RCW 9A.16.040 is not a general license to kill: the rest of the section details the conditions under which one can consider such use of force to be lawful. The officer must have "probable cause to believe that the suspect, if not apprehended, poses a threat of serious physical harm to the officer or a threat of serious physical harm to others". If that is so, "deadly force may also be used if necessary to prevent escape from the officer". Also, as usual, the fact-finders do not make that judgment post hoc, the officer at the scene does and he "shall not be held criminally liable for using deadly force without malice and with a good faith belief that such act is justifiable pursuant to this section".
In enacting this law (in case the courts wondered, years later, the legislature declared
The legislature recognizes that RCW 9A.16.040 establishes a dual
standard with respect to the use of deadly force by peace officers and
private citizens, and further recognizes that private citizens'
permissible use of deadly force under the authority of RCW 9.01.200 [since recodified],
9A.16.020, or 9A.16.050 is not restricted and remains broader than the
limitations imposed on peace officers
There do not appear to be statutory defenses for federal murder statutes, instead this results from common law interpretation, implemented in federal rules of criminal procedure (discussed here w.r.t. defenses) and jury instructions in the various circuits.