Somebody wrote this down in the ninth century
This is not a modern problem with an old label stuck on afterwards. Abu Zayd al-Balkhi, writing in the ninth century, described al-waswasah in a way a clinician today would recognise straight away. Thoughts that intrude and will not leave, and the repeated acts done to answer them.
He treated it as something to be helped. Not as a sin, and not as a shortage of faith.