Anapanasati will distance you from those thoughts due to exertion of effort to create a wholesome state by stilling the unwholesome formations. When you attain the first jhana thinking about doubt will be stilled on account of the power of wisdom, power of exertion and power of composure.
The distance is a thing and a wholesome is close to the wholesome and it is far from the unwholesome. Details on this are in the Abhidhamma.
The stilling of doubt can be tricky but the memorizing of expression so that one can penetrate the meaning is to an extent a must do.
Here on doubt from Sutta and the Vsm;
Doubt
A. Nourishment of Doubt
There are things causing doubt; frequently giving unwise attention to them — that is the nourishment for the arising of doubt that has not yet arisen, and for the increase and strengthening of doubt that has already arisen.— SN 46:51
B. Denourishing of Doubt
There are things which are wholesome or unwholesome, blameless or blameworthy, noble or low, and (other) contrasts of dark and bright; frequently giving wise attention to them — that is the denourishing of the arising of doubt that has not yet arisen, and of the increase and strengthening of doubt that has already arisen.
Six things conducive to the abandonment of doubt are as follows:
- Knowledge and pondering of the Dhamma
- Asking questions about the Dhamma
- Familiarity with the Vinaya (the Code of Monastic Discipline, and for lay followers, with the principles of moral conduct)
- Firm conviction concerning the Buddha, Dhamma and Sangha.
- Noble friendship
- Suitable conversation
In addition, the following are helpful in conquering Doubt:
Reflection, of the factors of absorption (jhananga);
Wisdom, of the spiritual faculties (indriya);
Investigation of reality, of the factors of enlightenment (bojjhanga).
C. Simile
If there is a pot of water which is turbid, stirred up and muddy, and this pot is put into a dark place, then a man with a normal faculty of sight could not properly recognize and see the image of his own face. In the same way, when one's mind is possessed by doubt, overpowered by doubt, then one cannot properly see the escape from doubt which has arisen; then one does not properly understand one's own welfare, nor that of another, nor that of both; and also texts memorized a long time ago do not come into one's mind, not to speak of those not memorized — SN 46:55