Because this kind of food is literally designed to be addictive. Particularly something like Maryland chocolate chip cookies.
So it's unsurprising when a 7 year old finds it....addictive!
Some people will be way more predisposed to it than others. I wouldn't expect those who can tuck the packet away & make it last a fortnight to understand!
It's not necessarily about lack of willpower, although is ADHD is a possibility, reduced executive functioning & a lower tolerance for 'deferred gratification' than same age peers might well be a part of it.
I know which particular triggers I have (MSG definitely, maltodextrin absolutely, anything combining fat/sugar/salt in general, yes). Typically I deal with it by not having crisps & biscuits in the house. I make cakes & sometimes biscuits with the children. But have to fill the cupboards with better options to eat.
Rules about asking for snacks will get you so far. Sensible conversations about healthy & balanced eating are essential, of course - without demonising any one product, but helping DD to understand that the food industrial complex literally WANTS her to overeat this kind of stuff of a regular basis! But helping her to know herself is the biggest thing.
If she came to you to 'confess' eating them all in one go, the most appropriate punishment might be to ask HER what you think you should do about it (together). She may already recognise it's a problem for her without knowing what to do about it, so helping with some practical suggestions might be a sensible path to give her the control to prevent things from spiralling into an eating disorder later in life. (Removing things from the house or diet altogether is unlikely to achieve this!)