Thoughts and memories are like bubbles. Sometimes they are sparked by events, sometimes they seemingly come from nowhere. We can observe them when they are forming, and importantly, can stop chain negative thoughts patterns.
Worries and anxieties are nothing but negative thought patterns. Something stirs our anxiety and we find ourselves a while later under a dark cloud. When you wake up from it, you don't even know anymore how you got there. It just happened on autopilot. Power to those who can spot the chain and saw the tracks before the train leaves the station. If you are conscious of the emerging thought bubble, you can just tell yourself "very interesting, but I choose not to go down this path with you.
You can also play a "Burst the Bubble" game which is fun and tells you a lot about the inner workings of your mind. The ego has different outlets for people, you can find it in the drive for professional power, sexual fantasies, the drive for more wealth, etc. Whatever it is that manifests your ego, observe how this bubble that is forming is related to something that just happened. Somebody flatters you or puts you down and out pops the ego-related thought. When you observe this naive mind connection you cannot help but laughing. This game is quite insightful and fun. Try it!