There are different theories of criminal punishment (i.e., different people subscribe to different philosophical justifications). Incapacitation is basically a special case of deterrence, in that you're deterring the individual who's in prison. Retribution is a little more controversial, but plenty of people see it as a valid goal.