Many of the unhealthy behaviors we perform are habitual. We are used to take a cookie with a cup of coffee or to have a late afternoon snack to beat our energy dip. Habits are formed when we repeatedly perform the same behavior in the same context.
Once a habit is formed, they are rather resistant to change. Preliminary research suggests that self-regulation strategies may help to break unwanted habits, or prevent that they are formed, but more research is required to substantiate this idea.