Your analogy is terribly flawed. You put 20 different kinds of dogs in a field and they will all play with each other.
But I didn't mention dogs, did I?
Sheep, goats, piga and cattle are all different species.
Dogs are members of a single species, as are humans.
Human races are much closer to the different breeds of dogs, although of course not nearly so diverse. I have never noticed any tendency of dogs to prefer the company of the same breed. I don't think they notice.
But some of the dogs, maybe just two in a mixed bunch of dogs, will assume leadership and become the "pack leaders." The rest will accept that leadership until one of the "pack" may fight to supplant a leader. Happens all the time with dogs (and their ancestors the wolves). My huge black Belgian sheep dog merely had to show up among other dogs and they all immediately seemed to recognize him as their logical leader. One low growl and they fell in line and stayed clear of him. Most people avoided and showed fear around him. The only people that needed to be afraid were those that tried to break into our yard and house. They left running and bleeding..