The Ghandi and Gandalf quotes are falsely used here for one simple reason: the death penalty is not the act of an individual taking revenge on someone for his or her crimes. The death penalty is enacted by a system made up of many individuals after due process has been followed. It is the action of a government that says that some crimes are repulsive enough that it is not enough to merely separate the perpetrator for the public safety, but that in the interest of deterrence and denunciation they must be put to death.
The legal system is intended to rely upon three factors when considering sentencing: rehabilitation ("Will the sentence provide an opportunity for the criminal to learn how to become a productive member of society?"), deterrence ("This sentence will serve as a warning to other criminals."), and denunciation ("The sentence will demonstrate that a civilized society does not tolerate crime."). Unfortunately, rehabilitation has become the key word, and denunciation and deterrence have been forgotten. (Incidentally, people love to use re-offend statistics to prove that harsher sentences don't work; well those who have been served the death penalty have a perfect 0% re-offence rate.)
Finally, the argument that a government has no moral authority to kill people when it expects its citizens not to is patently false. The government does a great number of things that citizens are not to do, with no one crying foul. The government takes our money, and yet calls theft committed by an individual a crime. The government prints currency, yet when a man does it on a laser printer in his basement, it's a federal crime. The government legalizes drugs for public consumption, but will not allow a person to take marijuana or cocaine. Government vehicles (fire, police, ambulance) are allowed to speed and run red lights, but individuals are ticketed when they try the same. Are all these examples of government hypocrisy? Of course not; they're examples of the government exercising its role: to provide a basic level of service and provision for all citizens, and to protect the public good.