Maybe you already saw this phenomenon and you were wondering what exactly was going on: several caterpillars line up and walk around following each other. The animals you might have seen are the larvae of moths, like for example of the pine processionary.
After spending the winter in tent like silken nests in pine trees, the larvae leave their nest between January and April by wiggling their way through the layers of their nest since it does not have an entrance or exit.
Once they made their way out of the nest, the caterpillars start the funny looking procession. During the procession, the hairy animals follow pheromone marked trails and stay so close to each other that they barely ever loose the physical contact. They can distinguish between old and freshly marked trails which allows them to meet at feeding sites and to find their way back to their nest. In addition, stimuli from the caterpillar in front helps to keep the procession together and is even more important than the secretion of pheromones. However, the larvae still depend on a trail marker.
In order to grow, the animals feed from pine needles until they are ready to burrow underground and transform into moths. Later during the summer, the moths find a new pine tree where they lay clusters of eggs in pine needles which will hatch in the next year.
Since the pine processionary feeds on pine needles and thus weakens the trees it is forest pest. Even though the procession of the hairy caterpillars is an interesting phenomenon, the appearance of the animal is considered as a threat not only to the trees but also as a hazard to humans and animals because the hairs of the larvea can cause serious irritations.
Sources:
https://en.wikipedia.org/wiki/Pine_processionary
http://wildsideholidays.co.uk/dangers-of-pine-processionary-caterpillars/