Hashem didn't make a mistake when HE designed the "laws of nature" yet at times he bends them to show HIS glory and strength. Even when Hashem does this there are consequences for such laws and laws of justice also apply to Him, lest He be unjust.
Baba Salí (OBM), a famous Rabbi whom Hashem performed great miracles through had deep insight into this concept. He was noted that during his prayers that some healings he could not pray for as a result of the consequences would be far more detrimental (in one case it was for a baby and he said if the baby were to be healed then the mother would be lost).
This helps to better understand why, "a prayer of the righteous can accomplish much" (James 5:16).
James goes on to speak about Elijah's prayer regarding rain, not for his will but of the will of Hashem. The laws of nature are part of Hashem's will, so there has to be a judicial reason to bend this law. Again there are consequences.
I think of Matt 7:21-23. Sure miracles were performed but neglecting HIS laws show we do not know Hashem or his Messiah. But instead it is those who does the will of Hashem who will enter (vs 21).
The fear of Hashem of the righteous seek to discern the difference and pray accordingly.
Pray, Love, Live in Shalom.