I remember reading these are called parasitic(?) thoughts, uncontrollable and random thoughts, sometimes leading to more complex reasoning but ultimately almost on autopilot ; like the mind is just suggesting many different things at once and you just happen to notice one of those random thinking when it reaches the surface of your consciousness. I belive it also has to do with an anxious mind but I have nothing to back that up.