Deterrence means to discourage someone from doing something that is against the law. Punishment may put someone off doing that action again. Seeing punishment given might also put someone else off doing the same action.
A purpose of punishment is to protect society from violent or dangerous criminals by keeping them in prison where they cannot harm others
Punishment should also help the offender to see what they have done wrong and to change, or reform, so they do not repeat the offence. This may mean providing criminals with education, skills or job training so they beome a law-abiding citizen agian. This is known as rehabilitaiton.
The idea that punishment should make criminals pay for what they have done wrong. It makes the victim of a crime feel a sense of justice - that the offender 'got what they deserved'.