Eli5: How do some animals/insects develop defense mechanisms where their coloring imitates a predator?



I understand learned behaviors is something’s brain getting bigger and gaining some IQ points. But how does the physical appearance adapt in ways to imitate a predator that benefits the host? How does the body know what a predator looks like?

In: Biology

Short answer is evolution.
Imagine there’s 3 different looking caterpillars, one brown, one striped and one pink. The brown looks like bark on a tree so it’s camouflaged and only get eaten by some animals that can see it. The striped looks like a snake so no animal wants to go near it and it doesn’t get eaten. The pink is obvious and gets eaten. When it’s time to reproduce, there’s more of the stripe snake looking one, so the next generation has twice as many snake looking caterpillars than pink. Repeat that over and over again, with each generation the ones that look more like a predator survive to pass on the genes

The body doesn’t know what a predator looks like. It gradually imitates the predator through random mutation and natural selection.

Imagine prey are all grey coloured and there’s a predator that’s yellow and black striped. Through random mutation, one of the grey prey animals is born looking a little bit stripy. This one is more likely to survive and reproduce than all the others. So in future generations, more of the prey are stripy. Then at some point later, one’s born that looks grey/black stripy. Well this one has an even better chance of surviving to reproduce so pretty soon lots more of them are grey/black striped. Then one’s born with a random mutation that makes it look more yellowish. Again, this is a big advantage, so this one survives to pass on it’s genes. It’s offspring have the same advantage and so on until all of them are yellow and blacked stripy.