Why do cookies prevent toothpaste from foaming?
My first take on this is that the cookies contain fat, which "consumes" the surfactants in the toothpaste (like sodium lauryl sulfate) so it does not foam up the way it normally would. You  might want to see what Wikipedia says about micelles and how they interact with fats. A similar effect can be seen when washing really greasy dishes with an insufficient amount of dishwashing liquid - in which case no suds will form. In your case I don't understand why the effect would not also be observed with other fatty foods such as chocolate or popcorn.