1. Even a bad habit has some functionality. (Even if a negative or illusory one. ) A bad habit "works" in some sense. It fills the time, or dulls the senses, or placates anxiety at some level.
2. The bad habit is based on faulty cognition. False beliefs. This comfort food will comfort me?
3. You can starve a bad habit, not by willing yourself into not doing it, but almost in the opposite way. Imagine if you see it as a battle of wills, or a very strong temptation. Then, of course, you are defining it as something good, to which you are voluntarily saying no. That would seem to be a losing battle, because why deprive yourself of something so great?
4. You can starve it out only by seeing the attractiveness of good habits. Something must seem more attractive than the alternative. What if playing piano will get you laid more than watching porn?