Looking at this picture, you might conclude that caterpillars have 8 pairs of legs- three pairs in the front, four in the middle and one at the back (if you're a bit confused, the head of the caterpillar is on the left in this photo). But wait, aren't caterpillars insects? Don't insects have 6 legs, not 16?
Like all insects, this caterpillar has only 6 legs. Note the different shape of the three pairs of legs near the caterpillar's head. They're the true legs. The remaining structures are not legs at all. They're protrusions from the caterpillar's abdomen called prolegs. Much like true legs, they help the caterpillar grip onto surfaces like twigs, and aid in locomotion.