This post is meant to be a catalog of the main categories of reasons given for why people who do bad things should be punished. I hope to use this as a basis for future posts.
This isn't meant to analyse their internal motives for punishing people, but their stated socially acceptable reasons (i.e. not 2I really hate the guy and this gave me an excuse to hurt him"). Please comment if you think I missed out a category.
In some cases punishment can prevent the person being able to commit the crime in the future. For example it's much more difficult to commit certain crimes in prison. This is relevant if you believe people who commit such crimes once are more likely to do it again.
The fact that a punishment is unpleasant discourages people from committing the crime if they expect they are likely to be punished. This can apply both to the person who receives the punishment, for whom the memory of the punishment will act as a future deterrent, and other people for whom the threat of punishment will do the same.
The idea that a wrong deserves another wrong, irrelevant of any benefits or costs of the punishment, or a desire for vengeance against the guilty party, irrelevant of any benefits or costs of the act of vengeance.
Some punishments attempt to right the wrong that was done by making the guilty party fix the damage done to the harmed party. For example fines may be of this type. In some cases the punishment may attempt to fix similar damage done to a third party - e.g. donating the fine towards an anti-racism charity after committing an act of racism against an individual.
It may be desired to signal that you do not agree with the actions of the guilty party. Punishing them can make that clear.
Some people may feel that the punishment atones for the harm that was done, meaning they are no longer (as) guilty for what they did.
In some cases the punishment may aim to change the worldview of the person undergoing the punishment in some way. For example sentencing somebody who parked in a disabled parking spot to community service at a disabled peoples charity may help make them more empathetic to the needs of disabled people in the future.
In some cases you may punish someone not because you personally see any of these reasons to punish them, but because other people do, and that gives you an incentive to do so. For example if other people won't associate with a criminal until he's undergone atonement, you may punish the criminal because you care about him, and want him to be able to interact with other people, even if you personally don't accept the idea of atonement. On the other hand, a politician may punish people in order to seem tough on crime - i.e. to fulfill the wishes of those who do see a reason to punish them.
Of course all these reasons are related to each other, and most peoples reasons for giving a particular punishment in a particular case are a confused tangle of lots of different concepts, often only vaguely formed. However I think separating them all out into distinct categories is a useful exercise for considering a utilitarian approach to punishment. I hope to investigate all of these in future posts.