Why it works: Self discipline often fails because it is counter to your impulses. Telling yourself not to eat that snack is pitting what you want now against a different thing you want for incomparable reasons that occurs later on. Good luck.
A better strategy is to exert self-discipline over something with no real opposition, a positive action. It takes much less self-discipline to force yourself to do something you don't want to do (e.g. flossing), then it does to not do something you want. (Furthermore, flossing and brushing, while not fun, have a reward in their completion.)
It's 9pm. You've already flossed and brushed after dinner, and now you see a cookie. You could easily eat that cookie, but... ahh, forget it.
Make it part of your life: after any food, floss and brush. Make the feeling of unbrushed teeth be unusual, uncomfortable-- not you.
Don't try to stop being something (a snacker); try to start being something else (a person who flosses and brushes a lot.)