It's a multifaceted problem. A lot of food ships with the eggs already in it, so if you don't use it promptly, you get a hatching. I tend to horde food. The way I buy, when there's a deal on something, I get a bunch of it. I like to keep grains in the freezer/fridge, but don't always have room, so it goes in the cabinet. Forget about it for awhile, and then you have moths everywhere :^S
I'm feeling good about this winter. I'll get all my grain stuff used up, and hopefully track down all the caterpillars, and kill them. Those things get everywhere, even outside of the pantry. They can be a real hassle.