Violence is certainly not permissible against any immoral acts. However, in the Law of Moses that detailed the covenant relationship between God and Israel, God did command certain punishments for various crimes, including robbery, adultery, etc. This is a function of community governance, though, and not personal violence. Furthermore, it only applies within the context of God's covenant relationship with Israel. It is how Israel was supposed to govern themselves as a nation--not how individuals should respond to others. The punishments did include capital punishment.
The Sermon on the Mount, by contrast, specifies behavior for individual people and not the government.
So, we do unto others how we want them to do to us, but we don't make that the rule of government. This would result in absolute lawlessness.