No, that does not necessarily follow. Were that true, ANY punishment for a crime could be said to be revenge because imprisonment is not necessarily seen as a deterrent in many cases.
I have always thought the imprisonment/death penalty are deterrents for a lot of people who have the opportunity to get involved with criminal activity, yet simply decide against doing so early on in their lives because of the possible consequences - death penalty being one of them. So they never have been offenders or repeat offenders and are never counted among those to whom these punishments is a deterrent, when in reality it was a very real deterrent in their decision to avoid criminal activity, altogether.