thats basically 99.9 percent why there's institutions like Psych hospitals, mental asylums and even prisons. They put you in prison to deter an offender from reoffending again through sentencing and incarceration techniques and what not. They serve as a form of deterrence, that attempts to discourage people from committing acts outside of the norm; and its definitely working in some ways, i mean we in this forum are instilled with fear that psych hospitals are overall bad and that all you do is suffer there, which thus makes us aware of the horrors in these institutions and asylums, and makes us deter our own selves from comitting certain acts.
Pretty much its a form of specific deterrence i think, theorists and crimonologists like Thomas hobbes and cesar becarria have talked about institutions of power and deterrence theory, and its still studied today in schools.