Minecraft wiki entry for Chunk, associated text: Some game aspects don't always get processed in loading chunks because there may be other conditions for their progress, which includes the following:
Chunk tick
Only chunks with centers within 128 blocks of a player are ticked on every game tick. See also Tick.
Entities
Hostile mobs instantly despawn if they spawn more than 128 blocks from any player.
This includes zombified piglins at Nether portals and witches in witch huts.
Passive mobs do not spawn naturally outside a 240 block X 240 block area around a player.
The passive mob spawn cap is limited by the number of friendly mobs loaded into memory, which means that any passive mobs present in the spawn chunks count toward the mob cap and usually prevents friendly mobs from naturally spawning anywhere else in the world. The only exception is when passive mobs spawn as part of a newly generated chunk.
See also Spawn.