New knowledge does not necessarily drive new results. Learning something new can actually be a waste of time if your goal is to make progress and not simply gain additional knowledge.
These are the primary ways that a new habit can be triggered. If you understand each of them, then you can select the right one for the particular habit that you are working on.
When it comes to building good habits and breaking bad habits, individual mistakes do not matter in the long-run. Instead, it is the second mistake that is far more important.