You know how dogs sometime teleport into the ground? Well, I've noticed that some mobs do it to. It's most common with slimes, but sometimes they'll spawn and glitch into the ground. This actually makes them invulnerable, yet they can still hurt the player. To reproduce try going into a swamp biome and you should get a slime or two in the ground if you haven't already seen a mob spawn in the ground.