So when harm afflicts man he prays to Us, then when We grant to him a favor from Us, he says, “”This has been given to me only on the (account of my) knowledge.”” No, it is a trail, but majority of them does not know.
During adversity man prays to Allah (SWT), when He grants his prayer, he ascribes the success to his own capability, by doing this he fails in his test. The consequence of such evil was and will be faced by all, though they might not know it.

