This is how, in my opinion, the wandering mind operates via a semi-crude analysis.
When you begin to type something into a search engine (e.g. you feed information into it) a list automatically begins to populate based on possible words that could be completed with those beginning letters. Sometimes, “you” become more interested in the subject that was brought up rather then the one you are actually looking for.
Also consider the highly unlikely, but probable, scenario in which an object falls onto a computer keyboard, inputting random letters into the search engine which will in turn begin to populate an autocomplete list.
In a similar sense, sensory data from every day life will prompt the wandering mind to automatically associate random memories, judgments, expectation, and thoughts with whatever is happening “outside”. This will often trigger other thoughts and memories leading to a chain of associations and driving us into our mental funhouse.