And is it a kind of gunnah because it means that I am not concentrated in my namaz?
Is there any way to cure this?
I am really scared because it affects my imaan seriously.

No it’s not gunah
You can pray to Allah to remove your doubts and improve your concentration in Namaz