Wrong. It is there to protect the public.
And how do you do that if you don't you know, try and do something to reduce the re-offending rate as well?
You can protect the public by executing everyone who commits a crime, but that's a little drastic even if it does reduce the reoffending rate to zero...
Or you can try and protect the public by a combination of punishment and sorting out what leads to some crimes, or punishment that leave the offender with nothing and few if any options other than to commit more crimes.
Oddly enough putting people in prison for a short period of time resulting in things like lost jobs and housing, then releasing them with nothing planned for once they're out tends to be really bad for crime prevention compared to punishments that often cost far less, but are also still punishments, often more so than a short stay in jail (a community sentence that say requires you to give up what is effectively weeks of free time is in some ways a harsher punishment than on that puts you inside for a week or two, whilst also leaving you able to work).
I'm sure you'd agree that jailing everyone who is caught speeding would be counter productive, but the argument could be made it would protect the public. But back in the real world the loss of the ability to drive is a huge and very disruptive punishment for most people.
Personally I'd like to see a massively increased detection and (safe) conviction rate for all crimes because it's usually not the severity of the punishment that causes criminals to stop but a combination or how likely they are to get caught and convicted, but combined with much more assistance to get people off drugs and to offer assistance to those who are committing crimes because of things like mental health problems or circumstances. This is pretty much the combination that has been shown to work time and time again as opposed to ever harsher and longer sentences with nothing else (back in the days of the "bloody code" crime was rife, despite the extremely harsh punishments, mainly because for many it was a choice of committing a crime or going without food/shelter etc).