Neat question.
The brain is composed of lots of highly-interconnected neurons. “Thought” is any communications across this network that manage to earn conscious attention. Consciousness is the part of the brain that can reflect back on itself. It’s an actual cluster of neurons and it can be turned off and on.
So, the mind, when it’s not focused on any particular task, localizes around an area of the brain called the “Default Mode Network.” This is where a lot of stuff concerning “self” resides. A reading of the Wikipedia page on the topic is recommended. Link
Not all the brain activity in the Default Mode Network reaches the level of conscious attention. Some of it is distinctly subconscious. But essentially the way consciousness works it that it recognizes patterns in brain activity. But the consciousness part of the brain is not the same part as the Default Mode Network.
If you’re are focused on something, the Default Mode Network tends to deactivate, unless it’s needed for that particular task. For example, I am currently focused on writing this answer right now, so the parts of my Default Mode Network that relate to this topic are active in my brain, but others, such as the recent conversation I had with a friend about how we both used to live around East Meadow, NY are inactive, except of course for when my brain needed an example.
“Deactivation” in this sense means less brain activity, not no brain activity. So your brain is still making connections and developing your self while you’re task-focused, you’re just not aware of it, that brain activity never reaches conscious awareness, so they don’t form thoughts that later get turned into memories.