This doesn't quite answer the question, but because you said "I have got some illnesses due to this too" ...
I find I'm bad with sweets. After I eat a sweet biscuit, I want another! After I eat a slice of bread, I want another!
Apparently some people get addicted.
Consider alcohol, for example: many people are able to drink a glass or two regularly; some people aren't able to drink one glass, they want to drink the whole bottle, they want to drink several bottles, they don't want to stop. For people who are unable to moderate their drinking it's better to not drink at all.
Or cigarettes: I heard of someone who used to have one cigarette per day. She was, perhaps not an addict? But for many people who smoke, once they start they can't stop.
So, sweets and bread, a month or two ago I stopped eating them altogether: which is better for me. If I don't think of those foods (sugar and wheat) as "mine" any more if see them, then I don't start to eat them and then it's not difficult to stop (because I already successfully stopped a few months ago). Like looking at meat, I don't find it attractive: the thought doesn't occur, "suppose I were to put that in my mouth and taste that ...", I lack any intention so there's never contact.
It's also easier to break contact if it's not around. If I stop buying meat, buying cigarettes, buying alcohol, buying bread, having biscuits in the cupboard and soft-drinks in the fridge, then it becomes easier not have them and to then be unable to stop having them.
For what it's worth when I quit eating meat (a long time ago) I found I'd still get hungry, so I learned to eat other things instead. If your intention when you eat is satiety and nutrition (which I think is canonical: wanting to remove the feeling of hunger but without causing a subsequent feeling such as feeling over-full) it's better to choose things other than sugar: e.g. vegetables, fibre, protein, fat, water, and traces of minerals and vitamins.
The Bhikkhuni Sutta explains 'eating to destroy old feelings [of hunger] and not create new feelings [from overeating]',
"'This body, sister, comes into being through food. And yet it is by relying on food that food is to be abandoned.' Thus was it said. And in reference to what was it said? There is the case, sister, where a monk, considering it thoughtfully, takes food — not playfully, nor for intoxication, nor for putting on bulk, nor for beautification — but simply for the survival & continuance of this body, for ending its afflictions, for the support of the holy life, [thinking,] 'Thus will I destroy old feelings [of hunger] and not create new feelings [from overeating]. I will maintain myself, be blameless, & live in comfort.' Then he eventually abandons food, having relied on food. 'This body, sister, comes into being through food. And yet it is by relying on food that food is to be abandoned.' Thus was it said, and in reference to this was it said.
I suppose there's one other thing I should say, about breaking the chain or changing the connection between "liking" and "intending": which is that maybe not everything you 'like' is good for you; and that craving is known to be a cause of dukkha.
Now you have experience of the consequences of "eating when I see sweets even I'm not hungry". Perhaps you see disadvantage or dissatisfaction in that (health problems for example). So maybe when the thought occurs, "I see a sweet: suppose I were to eat it..." then maybe you ought to have some 'second thoughts' about it: like, "... that would not be satisfying, I could eat it and then I would still want another"; or, "... I would feel remorse"; or something like that.