Someone who eats unhealthy food every day as a habit shouldn't just stop eating if they want to lose weight. That's not healthy either. Instead, create a new habit to always choose the healthy option no matter what.
If someone wants to quit smoking, saying "no" probably won't always be sufficient.
Being left alone to your thoughts when faced with temptation is most likely a recipe for failure. Sometimes you need to find a way to distract yourself from doing the things you don't want to do. The most efficient way to do that is to transform bad habits into good ones.
It seems obvious, doesn't it?
It's not easy (especially at the beginning) but eventually, you won't even have to think about it anymore.