It was rooted in the Cape Colony. The colonists lost and we’re replaced by migrants from the north, who outnumbered them and had to be controlled by brute force that couldn’t be sustained. Happens all the time in history and I don’t cry about it.
From what I know, the blacks who have subsequently taken over SA arrived after the whites, to work in gold/diamond mines, etc.
If my understanding is wrong, I apologize.