Castration was commonplace in the medieval and ancient worlds, with the procedure producing male vocalists who sang in the range of female alto or contralto, or who could then guard the ruler's women without the ruler fearing intrusion. Cyrus the Great had only castrated men in his personal service, including doormen. The "third sex" -- a reference term. It served to make them more tractable; or was used as punishment.
How was it done? There, upper right, above the pointed arch, an imp with nippers. Judgment Day. The losers.
Bern Cathedral facade, parade to doom
Some priests, the Gallae, did it to themselves, dedicating the act to Cybele, Phrygian goddess of nature and fertility.