Allah is the one who has set all natural laws, and the only thing He is under the influence of, is His own will. The one thing to keep in mind is that His will is that things take place through their natural causes. In addition to the fact that breaking certain laws in the subordinate world by higher powers is in and of itself also a law set by God and is possible; such a phenomenon is referred to as a ‘miracle’. Miracles aren't peculiar to the time of the prophets, they happen in every era, but only some are aware of their occurrence.
It is true that the limited science of every era does not confirm any magic and sorcery in the scope of its accepted propositions and definitions, but it is better and more correct to say that sometimes, these scientists see anything beyond their propositions and findings to be magic and sorcery, or to put it clearer, as a lie and superstitious.
The same way the different worlds of creation have different levels, God’s actions also have different levels, some of them overruling others and being able to intervene in them.
Breaking the laws of a subordinate world or realm by a higher power is itself, a specific divine law and possible that subtly happens all the time. The prophets were aware of these laws and would reveal some of them with the permission of God.
This isn't magic or sorcery; rather, it is a transcendent knowledge and power, and calling such a phenomenon magic just because it isn't bound by natural and material laws, is misuse of a term with negative connotations.
For example, there are some natural laws in this world that are overruled by other superior ones and work a different way and end up with different outcomes, nonetheless, this itself is a rule and law; only one who is unaware of this function will call it magic, add to that the fact that there is no end to the things unknown to us.
The truth of the matter is that aside from the miracles carried out by the prophets throughout history, there have always been phenomena taking place beyond the explanation of man and that of natural laws known to him.
It is very important for us to know that all levels of the world aren't bound to the limited laws that science has discovered so far, and not only can't these discoveries made by material sciences prove that such transcendent laws do not exist, but day after day, it is science that reaches the conclusion that there is much more out there than it has discovered, and that all the realities of the universe cannot be analyzed merely by limited facts and propositions discovered so far.