For me at least this comes from a bad habit of eating at night. Where I’m not necessarily hungry, but my body will associate bedtime with snacks before bed. The only way to really break this habit is to be aware of it and fight through it. After a couple of days it gets easier.
You can try brushing your teeth as soon as you start feeling like snacking, or using mouthwash. It’ll help you get through the first couple of days that are the hardest.
Sometimes I swear I feel hungry at night before bed and I am sure I won’t be able to sleep. But then I fall asleep. I’m the morning I try to remind myself that I wasn’t actually hungry and I slept great.
Just the anxiety of “what if I can’t sleep?!!” Can make me nervously scarf down food.