There is more than one form of castration: there are testicular and penile. The Unsullied are not castrated totally. This even comes up in the show when DDaenerys asks her handmaiden if it’s the root and the trunk, or just the root. sheShe replies, “I do not know.”
But in the books, there’s a mention of it as some point which makes it clear that it’s just the testicles. This was thought to have a focusing effect on the discipline of the soldiers. And while it does affect sexuality, it doesn’tdoesn't do so totally. In other words, a person who was had their testicles removed could very well be more or less sexually normal. They can still achieve erections and will ejaculate (just without any sperm).
There are some famous US cases of rape offenders being castrated in this way, then being released and surprising everyone by committing rapes again.