The mind will wander and that is part of its normal functioning because it needs to check out various aspects of whatever is brought to its attention. When it is totally fixated on one thing there is no thinking going on and thus no possibility to solve the problems confronting it. Conversely, when the mind wanders endlessly without ever coming to some stable points to work with nothing can happen either.
What the mind needs to do is to filter out those things that will probably help with an actionable idea and keep them in a readily accessible reference area. A problem arises if the ideas are unique because they will have nothing to link to and will be easily forgotten. They will not be easily recoverable because there are no links to previous ideas and only by going through the previous chain of ideas may these newly created ones be recoverable.
The solution to this problem of recovering really new ideas is to have some ongoing record of thoughts, especially new ones. That record can be in the form of notes, or audio recordings, or of memory tricks like giving the idea a vibrant name.
About seven independent ideas are all a normally functioning brain can work with simultaneously and as many of the dozens of potentially useful ideas will seem not to pan out and be useful. It is essential to have some record of them so they can be returned to at a later time. Even Einstein’s theory of General Relativity was an idea that he had passed over as unworkable several years earlier, but luckily he had written notes and was later able to build it up into the most important idea of modern physics.
Many of humanity’s best ideas required putting together seemingly unrelated ideas and it is common for great creative thinkers to be expert in totally unrelated fields of thought.
Pay attention to new ideas and at the first moment – record them.