Like you said, castration is haraam so the Ottomans and Arabs purchased already castrated slave boys from Christians in Egypt and Ethiopia. The castration process had a 10% survival rate so eunuchs fetched a very high price. I think they were only used in courts.I highly doubt they were castrating ALL slaves in the early days as the Quraan and Sunnah empathises on the haramness of mutilation. After the first couple of generations people definitely started to become less practising I suppose.
Masters didn't castrate their slaves because it would kill them.All slaves weren't castrated because their were some imported without being castrated and then their nice masters didn't castrate them.
This Wikipedia article goes into the Egyptian involvement but I can't find the Ethiopian part. I did read it somewhere though.what?? I didnt even know of this
Eunuch - Wikipedia
en.m.wikipedia.org