Where do my thoughts come from? What allows me to choose them at all? Regardless of whether free will is an illusion or not, what makes a thought happen? (This is a mix of a philosophical question and a biological one)
First, I think you'll find that most cognitive scientists do not believe in free will. It definitely is relevant to your question, because if you believe in free will, then you basically don't believe that our thoughts have causes.
Second, you'll be interested, I think, in the idea of spreading activation. Models based on spreading activation capture the intuition that our train of thought has an associative character (I think of castles, which remind me of kings, which remind me of giant drumsticks, which remind me of chickens, etc etc.). But don't get too hung up on this model -- associationism like this can only be part of the story (often our train of thought has a much more hierarchical structure).
Thomas Metzinger wrote a few interesting articles about this, he calls it Mental autonomy. (here's an open access article) The myth of cognitive agency: subpersonal thinking as a cyclically recurring loss of mental autonomy. Front Psychol. 2013; 4: 931.
This same query occurred to me about a year or so ago. And then I had some reason. Thoughts occurring at random is mostly dependent on our past experiences and environmental stimulus/stimuli, I believe. Regarding allowing/blocking one's thoughts, I guess it's partly conscious and mostly involuntary. But practice does somewhat improve the process. That's what I've come up to till now.