How to deal with compulsive snacking?

I've been logging my calories for 3 days now. I want to lose weight and read the starting tips to first just log what you normally eat in a day. Day 1 I had 2400 calories, day 2 fucking 3000, and day 3 (today) around 2500. I'm really shocked. I've lost weight in the past (like 7 years ago) and logged calories but even when I started then it wasn't this bad. I already have plans for how to improve my breakfast, lunch and dinner, but I'm really struggling with the snacks. Most of these calories come from snacks, so I'm wondering if anyone else struggles with this and/or knows how I can lessen it?

I know the obvious answer is to just stop eating them, or stop buying them in the first place, but I have this annoying... compulsion? I used to struggle with binging in the past and while that isn't very relevant anymore I still feel compulsions. They're especially bad when I'm bored, but also appear when I'm feeling fine. They're also a bit influenced by fear, I have an annoying fear of being hungry due to fainting in the past. The fainting was also caused by overheating, but my brain mostly latched on to the hunger. Sorry if it just sounds like I'm making excuses, maybe I subconsciously am, but I wanted to provide a little background 🥲

Anyway, I would really appreciate some help 🙏 and if anyone else relates to this, please share your story!