My understanding is that some hatcheries operate their own breeding farms, and others have contracts to buy eggs from farmers.
They keep separate pens of each breed, that are supposed to be chicken-proof so no accidental mixing takes place. When selecting the breeding birds for each pen, they should remove any with obvious flaws (like wrong foot color, or wrong comb type, or badly wrong size, etc.) But they will probably not bother test-breeding to see which birds carry recessive genes that should be culled, and they are not going to pick through large numbers of birds to select the best few for breeding. At a guess, if they need 100 hens for breeding, they probably try to hatch enough chicks to get 110 to 200 pullets, then remove the worst ones until they are at the right number.
They should be careful about which eggs come from which pen, keeping them sorted or marked as they go into the incubators, then having them hatch in different trays or different hatchers or some such system. Then the chicks should be taken out of the hatchers, sexed if needed, and boxed for shipmeny-- without being able to mix with other chicks.
Of course there will be a few mistakes (either from chicks jumping where they shouldn't, or from human errors), but the hatchery should make all reasonable efforts to keep such errors to a minimum.
Poking around hatchery websites can turn up quite a bit of information about how they do things. For example:
Cackle Hatchery has videos of their breeder flock for many of the breeds, which give some idea of how the birds are housed for one hatchery. (Look for a box that lists breed facts, description, videos, etc: videos are there if they exist.)
https://www.cacklehatchery.com/product/cinnamon-queens/
They have a large flock of parent stock for these. This exact "breed" is a cross of red roosters with white hens, which makes it easy to see how many males vs. females are in the building.
https://www.cacklehatchery.com/product/lakenvelder/
This is a smaller group, and at one point in the video I can see a wire-mesh divider with a different breed on the other side (they look like White Polish, about the 0:33 mark in the video.) I notice that they look quite different (so if a chicken accidentally does get into the wrong pen it will be quite obvious.) Also, if you look at the Lakenvelders, you will see that the color/markings differ a bit. The ideal is black neck and tail, with clean white everywhere else. The actual breeding hens & roosters have some with black necks & tails and some with bits of white showing there. Some have clean white on their bodies, and others have quite a bit of gray or black in places where it should not be. That is a good example of how "hatchery quality" can be different than show-winning quality for coloring and pattern.
https://www.cacklehatchery.com/tour-cackle/
This page has a link to a .pdf "Take a virtual tour of Cackle Hatchery 1999-2009"
It has photos and text.
https://meyerhatchery.zendesk.com/hc/en-us/articles/12987067569165-Virtual-Tour-Meyer-Hatchery
This page has link to youtube videos with tours of various parts of their Myere Hatchery operation (hatchery, breeder barns, etc.)
https://www.mcmurrayhatchery.com/history.html
McMurray Hatchery has a page about their history, with a link at the bottom to a video tour on youtube.
(Of course this is not a complete list of what hatcheries have on their websites, just some that I remember seeing before or could easily find today.)