A simple thought when followed with attention, can stimulate the mesocorticolimbic dopamine reward pathway. If thoughts are dwelled upon, it begins a process in the ventral tegmental area of the brain and causes a release of dopamine and endorphins (the body’s natural opioid). These underly the sensations of pleasure and euphoria and directly activate the globus pallidus which encodes the behaviors as habits.
The Buddha put it well in MN 19:
“Whatever a mendicant frequently thinks about and considers becomes their heart’s inclination. If they often think about and consider sensual thoughts, they’ve given up the thought of renunciation to cultivate sensual thought. Their mind inclines to sensual thoughts. If they often think about and consider malicious thoughts … their mind inclines to malicious thoughts. If they often think about and consider cruel thoughts … their mind inclines to cruel thoughts.”