I wish I was better at explaining this stuff, but I’ll give it a shot. But I’m not a theologian, not an apologist, not any kind of expert.
The death penalty has, until quite recently, been more or less in the same category as war. That is, something that is not inherently sinful, but that can be justified only as a last resort. It may be necessary for a nation to go to war to defend itself against an aggressor. And it may (but keep reading…) be necessary for a society to take the life of a violent aggressor to protect itself. While acknowledging this, popes since John Paul II have urged all nations to abolish the death penalty.
At that time, the Catechism said -
The traditional teaching of the Church does not exclude, presupposing full ascertainment of the identity and responsibility of the offender, recourse to the death penalty, when this is the only practicable way to defend the lives of human beings effectively against the aggressor.
If, instead, bloodless means are sufficient to defend against the aggressor and to protect the safety of persons, public authority should limit itself to such means, because they better correspond to the concrete conditions of the common good and are more in conformity to the dignity of the human person.
Today, in fact, given the means at the State’s disposal to effectively repress crime by rendering inoffensive the one who has committed it, without depriving him definitively of the possibility of redeeming himself, cases of absolute necessity for suppression of the offender ‘today … are very rare, if not practically non-existent’.
So the wrongness of the death penalty is conditional, not absolute.
Under Francis, the Church went a step further. The Catechism now says:
Recourse to the death penalty on the part of legitimate authority, following a fair trial, was long considered an appropriate response to the gravity of certain crimes and an acceptable, albeit extreme, means of safeguarding the common good.
Today, however, there is an increasing awareness that the dignity of the person is not lost even after the commission of very serious crimes. In addition, a new understanding has emerged of the significance of penal sanctions imposed by the state. Lastly, more effective systems of detention have been developed, which ensure the due protection of citizens but, at the same time, do not definitively deprive the guilty of the possibility of redemption.
Consequently, the Church teaches, in the light of the Gospel, that “the death penalty is inadmissible because it is an attack on the inviolability and dignity of the person”, and she works with determination for its abolition worldwide.
Pope Francis has also proposed the abolition of life sentences. I can’t remember the exact words, and Google isn’t helping right now, but he called it something like a back-door death penalty.
Abortion, on the other hand, is considered to be intrinsically evil by the Church. You (and I) may disagree with the Church, but it has consistently taught that abortion is intrinsically evil.
So, yes, abortion is different from the death penalty. One is intrinsically evil, the other is not.