Unwanted irrational wants

As an adult I have never been a sweet person, I am more of a savory person.
Whenever I am on a diet/protocol, I always seem to want things that I normally wouldn’t want.
I never feel the need to eat cookies, chocolate, ice cream, or sweets. I will always have a starter and never a desert. This changes when I am in a mindset of eating sensibly. I crave all of these sweet things.
Are you able to shed any light on this strange mindset?