Dragonflies (including damselflies, both in the order Odonata) are aquatic as larvae and terrestrial (and aerial) as adults. These are very different environments, and organisms need different adaptations to be successful in each one.
Dragonflies, like amphibians, have successfully colonized these two different environments. Some amphibians remain in water, and their immature and mature stages are very similar. Others undergo a dramatic metamorphosis when they move from water to land, for example tadpoles to frogs.
In dragonflies the changes are even more dramatic. A dragonfly larva (nymph) is so different from an adult that you would never think they were the same organism. Each is perfectly adapted to its environment, but they must change radically to move from one to the other.
Most dragonfly larvae spend months, in some cases years, in the water. Very tiny when they hatch from the egg, they begin feeding on other small organisms immediately. With an inflexible exoskeleton, they have to molt to grow, so they enlarge each time they shed their cuticle and grow a new one. Each of these stages is called an instar. Larvae usually go through 10-12 instars before they are full size.
While in the last instar, they begin the amazing transformation of metamorphosis. Within the larval body, tissues are transformed from larval to adult tissues. All this happens while the larva continues to move around, feed, and try to avoid being eaten by some other predator. Finally, the change becomes such that the larva switches from aquatic to aerial respiration. It cannot feed any more by that time, and it heads for a place to emerge from the water.
The larva crawls up onto shore or onto a stem emerging from the water and begins its transformation. It anchors itself in place by its sharp claws. Soon a split appears in the cuticle of the thorax, and the adult within enlarges and begins to emerge. The thorax and then the head emerge, and the dragonfly rests in that position for some time, presumably waiting for muscles to firm up.
It then reaches forward and grabs its own skin or the stem in front of it and pulls itself completely out of the larva (the cast skin is called an exuvia). It is still more or less the shape of the larva, but then it begins to enlarge still more while still soft. First it pumps body fluids into the wings, which had been accordioned into very small wing pads. The wings get bigger and bigger, finally reaching full size.