Nothing you said contradicts my assertion that sometimes NOT killing is the greater sin. I agree completely with your reasoning re the death penalty, and would go further and say that a failure to execute certain heinous violators constitutes an abdication of justice.
As I said, the decisions aren’t always easy.
Yes, if it is one’s duty to protect those under one’s care. Including one’s self. Not doing one’s duty is a sin against justice.
But killing is not the goal, but might be the means to securing peace, it depends on the situation.