From the shiurim on Kav Hashgachah
When someone fears some impending punishment, he should immediately daven and beg to be saved from it. That is the very reason Heaven brought this fear upon him. Our Sages teach that a person should always daven before troubles befall him. How is he to know that troubles are in his forecast, however? Hashem notifies him by making him feel fearful of something unknown. There are some punishments that cannot be undone once they take place; the only way is to abort them [through tefillah] and prevent them from materializing. Chazal call a person’s inner soul his mazal, and that inner soul can become aware of things that exist in Heaven that have not yet become the reality in this world. Through davening, one can mitigate an evil decree and even transform it into a blessing. (Based on Tzidkas Hatzaddik #169)
It Is Easier to Nullify in Advance
Before every endeavor, one should daven that it should be successful and bring no harm to him. Since it is before anything has happened, it is much easier to prevent any evil from taking place. That is why the custom is that, before the wedding of someone’s son or daughter, the parents daven that the middas hadin and ayin hara will not have any adverse effect on them. And this is the proper practice. (Based on Azharas Hakodesh, letter 7, of which the Baal Shevet Mussar wrote: “The words of this work are few, but they have enormous importance.”)
Pursue Tefillah All the Time
Now that the Beis Hamikdash has been destroyed, we have nothing with which to replace the korbanos other than tefillah and teshuvah. Therefore, a person should constantly pursue tefillah, and not only in times of troubles, but rather every day.... As Chazal teach us...and a person should constantly plead, asking that a multitude of angels should uphold and strengthen him. He should try to gain many friends, for every friend adds to his merits. As the Arabic teaching states, “Do not discount even a single enemy, and do not think that a thousand friends are sufficient. (Sefer Habechirah by the Meiri)
Tefillah Prevents Troubles from Coming
In Marganita Tava, an appendix to sefer Ahavas Chessed, the Chofetz Chaim wrote that a person should behave with the same submission and humility in peaceful times as he would feel during a crisis or dangerous times. This is what Chazal taught based on the passuk, “Did you arrange your prayer....” Actually, this is the most effective segulah to spare a person from harm. Most of the time, the reason Hashem causes suffering is that He wants people to pray to Him. Chazal taught that the reason our Patriarchs were barren was that Hashem longed for their tefillos (Yevamos 64). Accordingly, if someone will daven and plead to be spared all sorts of yissurim, there will be no need for him to experience them at all. The Chofetz Chaim wrote, “Be very careful” to maintain this submission and humility, meaning that if he does not take heed of this warning, he might be in serious danger, chas v’shalom. On the other hand, when someone feels the need to daven to be spared all yissurim, he will likely be spared. (Based on Shearim Bitefillah, Unit Bitzur, #7)