Knowing something does not guarantee that you will act rationally in response to it.
Willpower isn’t always up to the task of overcoming temptation.
One method of combating temptation is to refrain from acting on it.
It’s much easier to resist the siren songs of unhealthy treats if you go shopping after you’ve eaten, for example.