The line you quoted clearly makes a distinction between getting caught and being punished. Punishments are not the only possible response to someone having committed and being convicted of a crime. A heroin user could be put in prison or sent to a rehab program. One is a punishment, the other is not.
The action taken being against what the recipient wants to do with their time is not what defines a punishment. Punishments are correctional actions that rely on the power of violence deprive the recipient of something: money, freedom, comfort, life. Rehabilitation is a correctional action that relies on reason and education for the recipient.