It’s quite simple, actually.
The way I see it, a habit actually leads to a goal.
For example, if you want to have a clean body, you must develop the habit of washing yourself regularly. If you want to lose weight, you might develop the habit of working out.
What you do today influences what will happen with your long term goals.
This is the trick that eludes most people, when starting out, the goal is not the goal, but rather the goal is to create the habit(s) that will allow you to achieve your goal. Your first goal is to focus for as long as it takes to create a habit.
Once you’re on autopilot, it will be far more difficult to give up on working out, no matter what.