This page details the automatic and forced spawning of animals.
Forced Spawning Limits
It is nearly impossible to determine if there is a limit on the number of animals that will naturally spawn. Forced spawning using eggs may be equivalent or not but it the only way to make any determination. After some experimenting it was determined that you can only spawn up to 28 animals in a certain area. This 'area' can be rather uncertain, however.
For example, you can spawn 28 fish in a confined space, then the 29th attempt gives you the "TOO MANY ANIMALS" warning. If you then move about 60 blocks away, you can spawn 28 more. Instead, you could turn around and approach the first spawn area. As you approach it, you will notice that the fish will suddenly all appear to splash in the water. This happens within 40 blocks and is the fish 'respawning'. Once this happens, you cannot spawn more without moving beyond the 60 blocks again. But, if you stay just beyond the 40 blocks limit you could spawn an additional 28 animals.
You could try to force more animals into a tighter area by corralling these to join the others. They will strongly resist, as you are then attempting to violate the animal maximum. Some users report that the game lags when this is done. Perhaps more a powerful device would not lag as easily.
So, the game readily allows up to 28 animals within a 60 block radius. You can trick this down to a 40 block radius.
Within the 40 blocks it is extremely difficult and time consuming to get above the 28 animal limit. Also, both limits do not seem to be strict. The 'respawn' may happen at 32 blocks, up to 38 blocks. The 'unspawn' may happen anywhere from 52 to 58 blocks. If we assume the maximums, it's simplest to just call it 40 and 60 blocks.
Reduce Spawn Rate
The above effect shows a way to reduce the animal spawning near a house or farm. Simply ensure that the number of animals already in the area is close to or at the 28 animal limit. That will stop natural animal spawns within the 40 (or 60?) block radius. Animals that spawn outside of this area can still track you into this area but are still less likely to do so.
Kaalus has implemented an advanced animal behavior mechanism. There can be several behaviors the animal is engaged in at one time. Each is assigned a value according to how critical it is to the animal and the most critical behavior is the one that is executed. This lets an air breathing animal chase you even under water, but when it starts losing air, it will stop chasing and surface for air. They will also eventually 'get bored' with chasing you and give up, if you can outrun them long enough.
The 'chase you' behavior might conflict with the 'too crowded' behavior, however they have no issue with chasing you right into the crowd. Their wander behavior however, seems to generally keep them away from the crowd.
All animals have a natural habitat that they will spawn in. This does NOT mean they won't be present in other habitats, since they will certainly search for and follow the character.
It has now been confirmed that by making the floor from a non-terrain material AND providing sufficient lighting, random spawns will be prevented. To make a cave floor unnatural, you simply have to paint it or lay carpeting over it all. It is still unclear if ANY amount of light will prevent spawns but does seem that way.
Animals will despawn (disappear) when the character is too far away from them for too long. You need to 'visit' them at least within 24 days. Exactly how close you need to get is still being determined but it is likely the 40 or 60 blocks mentioned above