The bug: goats, camels and other animals are crossing fences and walls
how the bug happens: When the player moves away from the chunks where the animals are and then returns, the mobs get stuck or go through fences or blocks. apparently the mobs hitbox decreases for a moment or it loses the hitbox completely
Camels are naturally able to walk over 1.5 block high steps, like fences and walls.
Goats being in the ground/floor is tracked at MCPE-187268, so I am resolving this report as a duplicate.