Prison is also supposed to be for punishment.
Actually, there's a difference of opinion on that matter.
There are those who believe the purpose of prison is to reform the convicted, that prisons need to be reformatories. Their argument is that just sticking a criminal into a holding cell for a few years does nothing to change his behavior; in fact, it more likely reinforces the behavior by fostering a "me against them" attitude between the criminal and civilization while at the same time exposing him to like-minded people. Reformatories try to teach the criminal new habits and skills so that - when he is released - he can find a new path through life. The most extreme example of this is Sweden, although many nations in Western Europe follow this path to some degree or another. It appears to work for them but it is arguable whether or not their methods would have the same results in other countries.
The US, on the other hand, largely follows a philosophy of punishment (in concept if not enshrined in law); the idea is that the fear of prison as a punishment will keep people out of mischief. That is, if you go to a penitentiary you should expect to be stripped of all rights, beaten by the jailers, raped by the other inmates and probably lose the ability to ever find decent work once you get out, therefore it is better not to break the law. Whether this philosophy works or not I'll leave up to others to argue; on the one hand, violent crime rates have dropped dramatically in the country, but on the other hand, there are high recidivism rates and the US has the largest population of inmates in the world.
Then there is simple detention, a concept where there is no innate intent to penalize (or reform) the criminal; rather, the goal is to simply isolate the wrong-doer to protect society from his evil ways. These differ from penitentiaries in that they aren't used as a threat to convince people not to do crimes, nor is there any goal to reform the convicted. Detention centers are not necessarily unpleasant places (but due to budgeting issues usually are) Most often used for the irredeemable (repeat offenders, murderers, etc) when it is felt it would be too dangerous to let them go, or for people who are temporarily incarcerated before being banished from the jailing society (e.g., illegal immigrants).
Personally, I lean towards the first example as how prisons are best used, but in truth best results would be from a mix of all three. Unfortunately - at least in the US - too many people refuse to even consider that prisons should be anything but the most dire of dungeons, an attitude encouraged by a legal and penal system which benefits monetarily from ever-increasing criminalization and incarceration.
So prison doesn't have to be about punishment; we in America just chose to make it so.