It goes like this:
Egg--Larva (=Caterpillar)--Pupa--Adult(=Sphinx Moth)--more eggs.
An adult moth flew in and laid eggs on your tomato. They hatch into caterpillars that feed on the tomato plant. They crawl down the plant to pupate in the soil. When they're ready, the adult moths emerge and fly off.
In mild climate areas of California they may have up to three generations a year.
https://ipm.ucanr.edu/PMG/GARD....