On the one hand, as prisons can deprive a person’s freedom it would dissuade/deter people from committing a criminal offence/illegal activity. For example, if a criminal activity would deny a young man the freedom to pursue his favourite career or a happy life with his girlfriend, he is likely to resist the temptation of committing a crime. Moreover, the experience of being confined to a limited space for a certain period of time can act as great deterrent against crime.
Similarly, a great deal of social disgrace/stigma is attached to being detained in a jail. For instance, not many people would risk losing their honour/respect before their friends, family and society through imprisonment.
Furthermore, long imprisonment/incarceration can keep compulsive criminals and serial offenders away from the society and indulging in crime. To explain, psychopaths with criminal tendencies need to be separated from the mainstream of society as they cannot be reformed easily. All the above points clearly indicate the need for prisons to reduce crime in the society.
On the other hand, educating criminals about the implications of crime and supplementing to their educational and vocational deficiencies/inadequacies can definitely discourage them from committing further crimes to an extent. However, it can reduce the fear of committing a crime. Such methods cannot work independently but only as an addition to prison sentence.