The larva hatches from the egg. Butterfly and moth larvae are usually called caterpillars. Caterpillars spend most of their time eating. A caterpillar's exoskeleton can't stretch or grow, so the caterpillar sheds its skin, or molts, several times as it grows.
When the pupa has finished changing, it molts one last time and emerges as a butterfly or moth. It emerges with its wings folded up against its body. The butterfly or moth pumps blood into the wings to expand them. This is the stage when butterflies and moths mate and reproduce.