You're speaking of morals, not ethics. For example, abortion is legal and therefore medically ethical, although many people find it personally immoral.
But there are circumstances where abortion is both immoral and unethical, so it's fair to question whether it should be legal in all possible circumstances. There are individuals who would use it in a form that could be considered murder, and yet that wouldn't prove all medical professionals who would use it responsibly
are murderers (though some would claim that's the case). I think there are a lot of valid arguments against the death penalty that have been mentioned here, but I'm not inclined to believe the state only uses it to murder people in the majority of the cases. I think that may be the unfortunate truth in some (and there should be accountability in such) and in others it was a matter of the system failing in some step in the process (the redeeming evidence arrived too late, for example). The burden is on the state to ensure that innocent people are not executed, just as it has the burden of ensuring the same for troops and civilians in war. It can't bring back troops or civilians who die, and it's not likely to want to repay the resource debts which the citizens may feel it owes to them.