It's the guilt that's fattening, not the M&Ms. With no guilt, you just eat too many, feel sick, and aren't inclined to do it again soon. With guilt, all of your actions revolve around imaginary problems rather than reality, which is why it feels like you're going in circles with the same old struggles. We teach our brain what is important by what we focus on. If you teach it to feel bad, second-guess, and shame you every time you eat, that's what it automatically does.
Tabitha Farrar has some great YouTube videos on rewiring fear of weight gain, and I think a whole book on neural rewiring. Basically, that's the entire purpose of "doing the opposite." If you're terrified of weight gain, you behave as though you're not. If the fear is telling you to overexercise, you rest. If the fear wants you to cut the carbs out of a meal, you eat an extra helping. If fear says you can't wear that, you do anyway. If fear says freak out, you relax. Basically, in any situation, you behave as though weight is a non-issue, which trains your brain to quit worrying about it. Then you can finally begin to focus on how food makes you feel, whether you want it now, and if you even like it. Until then, all of that helpful information stays buried in the scary story of what your decisions mean for your weight, self-worth, and even survival. We've taught our brain that the stakes are very high. Life and death! That we need to worry about this a lot. Which is why it's so important to go through the process of countering those thoughts and behaviors with the ones you actually want. Every time the old disordered and restrictive voices pop up, they get called out and not acted upon.
I'll give you an example. The heat and humidity here has been horribly steamy. Walking outside is like opening a dishwasher mid-cycle. This situation makes clothes and jewelry stick to you, fingers swell, and just a general miserable, sweaty, puffiness set in. In this magical state, my diet brain threw out the idea, "How can I eat to feel less puffy today?" My logical mind came right back with, "Restriction Alert! What you're really asking is, how can I eat to feel less satisfied today?" Then I ate for enjoyment and satisfaction and to feel my best, as always, because the problem is the weather, not weight or food. So, even ten years after I stopped dieting, I still have those thoughts. They are weak now, probably tired of being laughed at and ignored, but they haven't gone completely away. They don't have to go away for life to improve dramatically. You rewire those old thought patterns, by rejecting them and not acting on them. If you want to be casual around food, you act casual around food. When you feel the hysteria rising, you deliberately squash it. You do, say, or think what someone without a weight concern in the world would do.
The eating disorder's immediate reaction will be to twist that concept into a story about how you'll gain so much weight, never stop eating, not care about anything, be so unhappy, woo, woo, waaaah... It's the same old lies though. Recognizing and actively countering disordered thoughts is THE healthiest, most freeing thing you can do for yourself. Then you can begin to experience genuine health and happiness instead of the eating disorder's twisted, abusive interpretation.
Definitely check out the Tabitha Farrar videos and resources on neural rewiring. They helped me tremendously, and she probably explains it better than I do.