All actions start off as thoughts.
Margaret Thatcher said this:
“Watch your thoughts for they become words. Watch your words for they become actions. Watch your actions for they become…habits. Watch your habits, for they become your character. And watch your character, for it becomes your destiny! What we think we become.”
And the Bible says this:
2 Corinthians 10:5 King James Version (KJV)
5 Casting down imaginations, and every high thing that exalteth itself against the knowledge of God, and bringing into captivity every thought to the obedience of Christ;
Thoughts are like seeds - they grow into words and actions. Evil thoughts have to be weeded out and prevented from growing into words and deeds.
Or, as Martin Luther said, addressing the same concept - temptation via the thought life:
“You cannot keep birds from flying over your head but you can keep them from building a nest in your hair”
― Martin Luther
The best protection/antidote to any external attempt to influence one's thought life is the Word of God - the Bible. Which is why, when Satan tempted Jesus in the wilderness, Jesus responded with Scripture.