Not defending him, but that kind of deal is made all the time for that reason. You’ve been in jail for 2 years and get told if you just say you’re guilty you can go free. If you maintain your innocence, you’ll still have to wait out the trial and face a longer sentence than the plea deal if found guilty.
Though admittedly, I might be willing to spend more time in jail if I was truly innocent of kiddy diddling. As this article is evidence, that shit will come back to bite you.