I've reviewed the entity spawning entry on the wiki, but I think I must be missing something. Judging from the wiki, you have certain environmental conditions, those conditions allow certain kinds of entities to spawn, and the game periodically checks whether an entity can spawn and whether you've hit the cap. I've noticed certain types of entity spawning in very nearly the exact same place over and over, but if conditions happen to be just right there, that still makes sense. However, if it were just down to environment checks, I don't think I'd be seeing behavior I'm seeing now.
I have a world I've been playing on since 21.6, and a fresh world made with the same seed and world settings in 22.2. Geographically, the two are identical or very nearly so. /wgen pos climate shows that the same locations on both worlds have the same conditions that should affect spawning. However, in places where the new world generates red river hogs, the old one only generates gray hogs. It's not that the new pigs aren't showing up at all, because if I wander far enough out into desert areas I hit warthogs, but these desert areas are either newly generated or recently regenerated. That suggests to me that some aspect of animal spawning is controlled by *something* in worldgen, possibly a spawner meta block or something similar, and that the old world is generating gray hogs in places red river hogs would otherwise generate for the same reason it still has traders in wagons: that's what was there in 21.6. That said, it's hard to be certain, since there are other possible explanations; maybe the spawn cap is for all pigs and red river hogs won't show up until the old gray hogs die off, or there's some environmental condition I've missed. Heck, since gray hogs spawn in such a wide range of conditions and red river hogs spawn in relatively narrow ones, it could just be odd luck.
So, how do animal spawns work? What controls where and how they spawn? Is it really just those environmental conditions, or are there other factors in play as well? It's not an urgent question, but I am curious.