There is a counter example which is Afghanistan which obviously had bad governments and currently is a theocracy but decline of Islam doesnāt seem to be happening but obviously Iām not educated on the situation there.
The only reason I can think of is that maybe foreign invasions had an effect on religiosity because usually people are more religious when hardships are occurring like I assume if Iran would get invaded by the US then Islam would be on the rise even if the current Iranian leadership would be the ones leading the defense.