At the very least, it evolved twice – amphibians employ it because they have to lay their eggs in water because they need water to flush away embryonic piss. More advanced vertebrates use other solutions, involving processing urea into uric acid, which can then settle out in the egg (reptiles, dinosaurs, birds, and monotremes), or letting the mother take care of the problem (placental mammals). (I don’t know about marsupials.) Insects, on the other hand, use metamorphosis to help solve the problem of growth with an exoskeleton; a caterpillar can molt much more easily than a butterfly could.
In both cases, only the actual metamorphosis process had to evolve. Frogs, having fish ancestors, have no great problem starting life as fish. Insects, having worm ancestors, have no great problem starting life as worms. (“Ontogeny recapitulates phylogeny” is only partially true, but it is partially true, especially when it happens to be useful.)