For me a lot of it is a case of "out of sight, out of mind". I don't keep junk in the house as a rule, however, this rule has been bent in recent years because of Covid and scarcity of resources.
But when I do buy junk I try to get stuff which is pre portioned. So it's very easy for me to eat a tub of Ben and Jerry's; I don't like doing dishes so I'm unlikely to scoop out a portion. Therefore, I buy Magnum or a flake, so that I only eat that one portion instead of an entire pot.
Similarly, I will not buy a large chocolate bar, but I will but a multipack of smaller things.
Some things are just out of bounds except for special occasions or eating out: alcohol, fizzy drinks mainly.
I personally have an oral fixation, so I keep my mouth "busy" with a pomegranate or something equally fussy to eat as a snack/dessert. It's delicious, low in calories, and keeps me occupied for at least 20 minutes.
The other thing is having a set of simple go-to meals for dinner. Simple, healthy ish things like tuna pasta, an omelette, or rice and veggie sausages with broccoli. This reduces the likelihood of ordering takeaway. Follow the recommended portion guidelines, even though I think 70g of pasta is small and 50g of granola is a joke. I do use blue milk though, which helps.
Also, endless cups of hot beverages: black coffee in the morning, earl grey tea in the afternoon and herbal teas in the late afternoon/evening.
Going for a walk after dinner, before the food coma kicks in, is also good for you.