Having predictable punishment and swift enforcement prevents other potential criminals from committing a similar crime. Some studies have concluded that capital punishment is not a greater deterrent than imprisonment. Some prisoners even prefer death to a lifetime in prison. Even if the death penalty deters crime, deterrence alone does not justify the penalty. The death penalty might deter shoplifting, but most folks would agree this would be a rather excessive penalty for minor theft.
Deterrence has to be balanced with the human rights that even criminals have.
The fourth reason for proper punishment is the restitution of the damage. If a thief steals property, he is morally obliged to return the property to the victim, or property of similar type or value. If society kills the criminal, this cuts off any possible restitution. If the criminal has committed murder, restitution to the victim is not possible in any way. Killing the murderer will not restore the life of the victim.