No one can really answer your question except Allah, then you. This is a test, but here is how you can try to figure out the cause. It is a test to all, believers and non-believers alike. Tests and tribulations are what distinguishes between one who is sincere and one who is lying.
The Prophet said in this long hadith (only partially quoted):
تعرض الفتن على القلوب كالحصير عودا عودا فأي قلب أشربها نكت فيه نكتة سوداء وأي قلب أنكرها نكت فيه نكتة بيضاء حتى تصير على قلبين على أبيض مثل الصفا فلا تضره فتنة ما دامت السماوات والأرض والآخر أسود مربادا كالكوز مجخيا لا يعرف معروفا ولا ينكر منكرا إلا ما أشرب من مراه
Temptations will be presented to men's hearts as reed mat is woven stick by stick and any heart which is impregnated by them will have a black mark put into it, but any heart which rejects them will have a white mark put in it. The result is that there will become two types of hearts: one white like a white stone which will not be harmed by any turmoil or temptation, so long as the heavens and the earth endure; and the other black and dust-colored like a vessel which is upset, not recognizing what is good or rejecting what is abominable, but being impregnated with passion.
If, when you get your doubts, you reject them and ward them off and you do not follow with committing sins, your faith is sincere. If your heart is affected by the doubts to the extent that it leads you to sin or to stop fulfilling your worship duties, then your faith is not fully sincere. This is not a binary situation, where not fully sincere automatically means kaffir, but there are so many degrees and levels.
Imam Al Nawawi in his explanation of the hadith above is that when a man goes through tests and tribulations that are followed by sins, his heart goes one darkness after another, until the light of Islam is removed from his hear in its entirety. This concept is also confirmed by another hadith in Musand Ahmad (with my own translation, as I could not find one online):
أحسنوا إلى أصحابي ثم الذين يلونهم ثم الذين يلونهم ثم يجيء قوم يحلف أحدهم على اليمين قبل أن يستحلف عليها ويشهد على الشهادة قبل أن يستشهد فمن أحب منكم أن ينال بحبوحة الجنة فليلزم جماعة المسلمين الجماعة فإن الشيطان مع الواحد وهو من الاثنين أبعد ألا لا يخلون رجل بامرأة فإن ثالثهما الشيطان ومن كان منكم تسره حسنته وتسوءه سيئته فهو مؤمن
[My own translation, so treat with care] Be good to my companions and those who follow them and then those who follow them, and then there will come people who solemnly swear before being asked to swear, and testify before being asked to testify. Whoever from among you wants to attain the vastness of Jannah, observe the congregation of Muslims, for the shaytan is with the sole one and he is farther from two people together. A man should never be alone with a woman, for the shaytan will be their third. And whoever among you who is pleased with his good deeds, and is troubled by his bad deeds, he is a believer.
So, when you get such doubts, follow your doubts with good deeds, and seek refuge in Allah as the Prophet said in this hadith:
يأْتِي الشَّيْطَانُ أَحَدَكُمْ فَيَقُولُ مَنْ خَلَقَ كَذَا مَنْ خَلَقَ كَذَا حَتَّى يَقُولَ مَنْ خَلَقَ رَبَّكَ فَإِذَا بَلَغَهُ فَلْيَسْتَعِذْ بِاللَّهِ وَلْيَنْتَهِ
Satan comes to one of you and says, 'Who created so-and-so? 'till he says, 'Who has created your Lord?' So, when he inspires such a question, one should seek refuge with Allah and give up such thoughts.
EDIT: One more point is that you need to always say the duaa' of the Prophet in this hadith:
يا مقلب القلوب ثبت قلبي على دينك
O Controller of the hearts make my heart steadfast in Your religion
It has a few other narrations (1, 2, 3)