The short answer is: those “unhealthy things” hack directly into our bodily reward system.
Thus, we get an immediate reward (usually: pleasure) from doing them. We crave the pleasure, so the behavior gets reinforced. It easily becomes a habit.
The long answer is more complicated.
The reason why hacking directly into the reward system works so well is that it bypasses the conscious mind. The subconscious mind knows only one tense: now.
It is not concerned with the future ramifications of present actions. And it’s quite a primitive creature. Do you feel pleasure? Well, it means this action feels good! Let’s repeat it and get the same pang of pleasure!
No reflections. No pondering of consequences. And your bad habits create on autopilot.
Good Habit Are Easy
Getting hooked on healthy habits is not so difficult. It seems difficult only in comparison with the “zero-effort” way bad habits form.
One of my healthy habits is to eat at least one raw vegetable or fruit a day. It’s very easy. All I need is to remember about the habit (now, after several years it’s my second nature), get a veggie, and munch it.
Yet, it still takes some effort, some investment on the part of my conscious mind. I need to remember. I need to have veggies or fruits at my home. I need to actually perform the action.
It’s even more bothersome at the very beginning when the whole routine is new to you. Even remembering the habit can be an effort. Then, you need actually do it. It’s also beneficial to track it. It’s all the mental effort.
And the reward is not so big. Well, in the beginning, it’s hardly noticeable. And it is certainly not immediate. You switch your diet or exercise for a week before you can see any significant movement on a scale (a few pounds). But you don’t want ‘any!’ You want ‘many!’ And you don’t want them next quarter, but yesterday!