Oftentimes weird traits animals possess happened to naturally result from survival of the fittest scenarios. If shorter giraffes aren't able to reach leaves, they will starve and die off. Eventually, just the ones with the longest necks will remain.
If caterpillars with a tail that looks like a snake's head have higher survival odds, their tails will naturally start looking more and more realistic over many generations. Any with tails that mutated in less than ideal ways, got killed off.
