If I can add my 2 cents worth... In my experience, the best drivers in the world lose their focus/concentration just as much as anyone else. What they do better than most is regain it quickly. So, it's not just how to stop yourself from losing focus - it's being able to regain it quickly that matters.
What do most drivers focus on when they lose focus? The fact that they've lost focus (wow, that's a lot of "focus" in two sentences!). And the more they focus on having lost it, the more they stay un-focused. The key is having a "trigger" to regain focus. For example, if you program yourself so that every time you lose focus, you say the phrase "eyes up," you look further ahead and your focus comes back to what you're doing in that moment - and you will quickly regain focus.
It takes practice (programming), though. Why do we as humans do what we do? Because we're programmed to do so. Why do we NOT do what we want to do? Because we're NOT programmed to do it. Practicing (programming) quickly regaining focus by using a trigger word or phrase is the key. And everything else others have suggested here all help make that happen, too.
It is comforting to know that if we lose focus, we're no different than Fernando Alonso, Joey Hand, or Jimmie Johnson. They've just practiced regaining focus more than most.