It seems clear that thoughts involve brain-neurones, because damage to (or a reduction in the number of) neurones makes rational thought more difficult. But, like, the exact physical and/or biological micro-mechanisms which lead to the formation of ‘thoughts’ are completely unknown.
“Though thinking is an activity considered essential to humanity, there is no general consensus as to how we define or understand it.”
source - Wikipedia
Although current scanning technologies (fMRI, EEG & etc) are able to detect minute changes in human brain activity - to the extent that external machinery can now be 'controlled by thoughts' - the instruments are in reality detecting minute but measurable changes in the brain (electrical activity, increased blood flow etc) caused by the process thinking, rather than the thoughts themselves.
Many people find thinking in order to resolve complex problems uncomfortable, even 'painful'. This aspect is under-researched and as yet unexplained. A groundbreaking experiment published in Science journal, 2014, found that groups of experimental subjects who were simply asked to sit alone with their thoughts for fifteen minutes, preferred, in general, to self administer painful electric shocks instead.
“[…] what is striking is that simply being alone with their own thoughts for 15 min was apparently so aversive that it drove many participants to self-administer an electric shock that they had earlier said they would pay to avoid.”