Saint Theophan tells us,
Steadfastness and continuity of labor over oneself is an essential condition for success in the spiritual life. Lasting pacification of thoughts is a gift from God, but this gift is not given without intensifying one's personal labors.God is all loving but He will not give us something unless we put our full effort into it.
Saint Macarius the Great says,
It is necessary to force oneself even in prayer, if one does not have spiritual prayer... God seeing that a man is calling with effort and restraining himself (that is , his thoughts) against the will of the heart, grants him true prayer.True prayer is a prayer that is not distracted by any thoughts, where one is absorbed in prayer, where the mind stands before God. In this state it does not want to leave this place with God.
The dangerous condition is where we voluntarily allow our thoughts to wander. Here is some advice from Saint Theophan when we are faced with involuntary thoughts during prayer. He says, "When your thoughts stray involuntarily, you must immediately turn them back, reproaching yourself, regretting and grieving over your weakness."
Saint Theophan also suggests that it is helpful to memorize your prayers. Even better is to go to a church and pray. But where we mostly pray, at home, we need a place where we will have minimal distraction, the comfort of icons, a cross, and candle lamp.
Saint Theophan also suggests that we prepare ourselves for prayer.
Make some preparations for prayer, trying to collect your thoughts ahead of time and direct them toward standing worthily toward God. Rouse within yourself the need for prayer at this particular time, because there may not be another time. Do not forget to renew the consciousness of your spiritual needs and for the most immediate real need of all––the settling of your thoughts in prayer with the desire of finding satisfaction for them, namely in God. When there is is this consciousness and the feeling for such needs in the heart, the heart itself will not allow your thoughts to wander off to something else, but will feel more keenly your complete helplessness; without God, you are completely lost... Go into it with a feeling of total misfortune and the consciousness that there no one who can deliver you from it except the One God.More on attention in prayer
Reference: The Spiritual Life, pp 209 - 212