Passive mob glitch
A glitch occurs where passive mobs will glitch out of the fence but soon it corrects itself and they glitch back in. It is a very common glitch and has been in the game since at least 1.3.5 beta. One of the easiest ways to recreate the glitch is so spawn ALOT of mobs in a small area.