most of the time it doesn't do any good.
Mainly due to the prison system itself (Monday: counselling. Tuesday: prison rape. Wednesday: being beaten unconscious.), and the fact that if someone is imprisoned as a murderer, once they're released they are free to go, but for sex crimes, once released, they have to register as a sex offender and can never again live a normal life.
Basically the system doesn't want
to rehabilitate people or help them, it just wants revenge for crimes, more in line with a barbarian tribe than a civilised society. So no real help is provided to criminals of any variety, and in plenty of instances, they reoffend because they weren't honestly helped to stop doing so.
That and the fact that mental help would rely on it being a mental disorder - I'm willing to believe many paedophiles think the way they do because of mental issues that therapy and medicine can help with, but plenty more do not. So for the person who likes kids because they're afraid of adults and can't form proper adult relationships, that would help. But for the person who simply likes kids since birth and doesn't have the ability to not act on desires/channel them through other means (writing, watching more than half the hentai out there, whatever), or for the person who has been exposed to too much "Let's dress 6 year old children up as street prozzies! It helps them feel more grown up!*"... in those cases, there may not be a real answer other than to convince them not to act on urges.
*I congratulate all parents who resist this trend. Besides, that form of dress looks ugly, so we don't want people growing up liking it!