However, when Allah afflicts a slave and decrees that for them, He helps them, but when they expose themselves to trials, Allah entrusts their affairs to themselves. The Prophet, peace and blessings of Allah be upon him, said to Abdul-Rahman Ibn Samurah, may Allah be pleased with him,
“Do not seek out leadership, for if you are granted it through seeking it, you are responsible for it, and if you are granted it without seeking it, you will be helped in it.” (Bukhari)
Similarly, he, may Allah’s peace and blessings be upon him, said regarding plague:
“When it falls upon a land and you are there, then do not leave trying to escape it. And if you hear of it in a land, then do not proceed to it.” (Bukhari)
Thus whoever does what Allah commands him then a trial befalls him without choice, then indeed Allah will help him with it as opposed to those who expose themselves to trials.
Garden of Purification by Ibn Taymiyyah Page 50