The Church is against capital punishment with the rare exception of when it is necessary to protect the innocent.
Read section No. 2267 under Legitimate defense
Also, understand that there is a difference between killing and murder.
- Murder, by definition, is the intentional killing an innocent human being.
- Killing is permitted if necessary to protect the innocent from an unjust aggressor, which falls under the principle of legitimate defense.
See # 2264 on the same section. Because there may be rare times, at least hypothetically, when capital punishment could be legitimate, it is not intrinsically evil like abortion and euthanasia. No possible situation or circumstances could ever justify those acts, which are the killing of the innocent.