The verb wander describes something that has lost track. If you're watching a boring movie, your mind might begin to wander. If you don't have a clear goal, you could wander too — meaning you drift aimlessly.
When you wander mentally, your thoughts get lost. And when you wander physically, you don't have a destination, so it's also possible to lose your bearings and not know where you are — or how to get back. That's why wander is also used to describe someone who drifts from place to place or job to job without a sense of direction or purpose.