mobs took damage when they are over 25 on 1 by 1 block
When the density of mob is over 25mobs on 1 by 1 block, mobs take damage until there density is reduce to 25mobs in 1block².
I am not sure that is a bug or an hidden feature but it is quite usual to exceed this limit in automatic or semi-automatic farms and may break a lot this farm.
In the attached pictures, you can see 25 creepers in a 1by1 block cage. When I spwan other creepers with eggs, creepers take damage and die.