By being watchful in prayer.
Being watchful is learning to be aware of erroneous incoming thoughts and to let them go rather than attach commentary to them.
For me, quiet prayer works.
Sitting in a quiet place with my eyes closed, I begin to say the name of our Lord silently, “Lord Jesus.” As I say this prayer word, I turn inward and move to the center of my being where Christ dwells. I merely focus on his presence and when I find a thought coming into my mind that is other than Jesus, I return to the prayer word, “Lord Jesus.”
Eastern Orthodox Saints teach the Jesus Prayer, and I have used this as well.
One of the people in my Secular Order Discalced Carmelite group taught this prayer,
“Be still and know that I am God.” Repeat the prayer, and when you suddenly become aware that you’ve been distracted with a thought, return to the prayer but leave off the last word, i.e. “Be still and Know that I am.” Next time, leave off the last again, i,e, “Be still and know.” Eventually, you’ll come to, “Be Still.”
Obviously, the more you pray, the better it becomes and you’ll begin to notice a stillness within, through out the day.
Jim