Punishments for crimes are not merely deterrents; that is a secondary role.
Punishments are ... punitive, of course!
Suppose you break into someone's house and steal 50 bucks. You aren't just forced to return 50 bucks; you go to jail for a while.
Even in civil suits, there are "punitive damages": remedies awarded to a plaintiff beyond actual damages.
If you kill someone, then killing you is not even punitive really; it's like taking 50 bucks from someone who stole 50 bucks. The revenge is less than punitive. It's not true revenge. True revenge has a punitive aspect: it goes beyond the original offense. Killing is only revenge if the method is more fearsome and painful.
If a killer tortures someone to death, but is given a quick and merciful death, that falls short of revenge.
Anyway, deterrent value must never be the focus; that is a pseudo-intellectual liberal angle which detracts from the morality of the situation, which is about justice.
If a punishment's ability to deter is considered important, that leads to injustice. For instance, big punishments are handed down for small crimes to "make an example" which discourages others. E.g. six month prison terms aren't deterring petty pickpockets in some area, so we crank it up to five years.