<< How did they get in there in the first place?!?!? >>
Well, the boxes aren't perfectly sealed, and I hate to break this to you, but we eat food that has insect eggs in it all the time; it's not just rice-a-roni. Usually we eat the food long before they have a chance to hatch, but it is virtually impossible to prevent 100% of the food from ever getting bug eggs in it.
I've seen the same sort of thing happen with pasta, only the bugs were microscopic, most people wouldn't have even noticed them.
Also happens in birdseed a lot, or any sort of grains. If you have anything like that in your house for a real long time (especially in bulk), you WILL have moths eventually; either they'll find the food or they'll hatch from it.