Couldn't one argue that warfare is essentially a form of state-sponsored murder, and one that seems to get far more of a free pass than the death penalty? I'm asking only as a devil's advocate and I agree with all of your Ifs, I'm just not entirely convinced that the state is inherently murdering when there are circumstances that might cost an extremely dangerous and clearly guilty offender their life.
A legitimate war (rare these days) can be justified as a form of self-defense.
And I would argue that self-defense is the only justification for killing someone.
Once a person is in custody, in a cell, under guard, the self-defense argument is lost, IMHO.