That's called hypocrisy. Teaching but not doing.
They used them as choir singers but the practice has always been condemned and those found doing the procedure were often excommunicated.
The Catholic Church is infallible in the teaching of faith and morals. The Pope does not make mistakes when he speaks “ex-Cathedra”, or from the chair (which is rare - most Pope’s do not issue infallible decrees). But administrative mistakes may be made - continuing to allow castrated singers may have been one. Remember though, those castrated boys claimed it was a tragic “accident” that led to the castration. This was usually a lie and done so they could get to sing at the church.