This is already the case in a few US states. And I have to say, I think it’s staunchly unconstitutional per the 8th Amendment’s stipulation of ‘cruel and unusual punishment’. The second that someone is found innocent after they’ve already been castrated, I hope the government sees how much of an abject failure this is. Not much more or less than the death penalty.
Any form of punishment that can cause lasting harm is cruel and unusual in my opinion. If even one innocent person is wrongly convicted that is an unjust system. And the right wing seems eager to witch hunt LGBT people and call them groomers for the mere act of existing and teaching acceptance. They'd love to burn trans folks at the stake if they could get away with it.
I think that it’s a fitting punishment for the crime. But I not only think that it will not deter predators, but I think the potential ramifications for innocent people getting accused is too much of a risk to consider. If they’re going to use this, they better be damn sure. I’d also like to add that castration does not affect sex drive, so this quite literally only serves as a method of torture. And once they get out, they will not have a decreased desire to reoffend.