While all miracles are extraordinary displays of divine power that go beyond the ordinary course of nature, some are perfectly in accord with the laws of nature, such as the miraculous catches of fish described in Luke 5:1-11 and John 21:1-14. However, some miracles almost certainly contravene the laws of nature, such as Christ’s miraculous feeding of the 5,000 and his turning of water into wine. Does that mean that such miracles are “impossible”? No. For if God established the laws of nature, he can also suspend or make exceptions to them.
It is true that there are some kinds of laws that cannot be suspended or have exceptions made to them, such as the laws of arithmetic: 2 + 2 must be 4 and could not be anything else. But the laws of nature do not have that kind of “absolute” or logical necessity. Whereas arithmetic cannot have had different laws than it does, the physical universe could have had different laws (or no laws), which is why the laws of nature had to be discovered by doing experiments.
The laws of nature can be compared, in this respect, to the rules of a game, such as chess. The moves of a chess game follow certain rules, not by absolute or logical necessity, but because someone decided that chess should be played that way. So why do natural events within our universe follow the rules that they do? Why not some other rules? Or no rules? Isaac Newton, who discovered the laws of mechanics and gravity more than three centuries ago, believed that these rules exist because God imposed them on the universe as its Creator and Lawgiver. Indeed, historically that is where the very concept of “laws of nature” originated.1 In fact, this concept has even deeper historical roots. Early Christian writers described God as the “giver of order” to the cosmos.2
One can ask why God, having established certain rules for nature to follow, would cause some events to occur that do not follow them. Catholics believe that these rare and exceptional events are meant as “signs” whose purpose always relates to the salvation of souls. These extraordinary signs show that God has power over nature and can therefore rescue us even from death --- the central miracle in God’s plan of salvation is Christ’s resurrection from the dead. Many miracles involve physical healing. Such miracles both remind us of God’s love and symbolize the more profound and important healing --- from sin --- that God offers to all. Miracles are also signs that certain persons (e.g. Moses, the prophets, the apostles, saints, and Christ himself) have a mission from God and speak and act by his authority, since only God himself, the Author of Nature and its laws, can cause a miracle to occur.
The belief in miracles is not contrary to belief in a lawful universe. If nature had no rules, there could be no extraordinary exceptions to them that serve as signs. And virtually all the great figures of the Scientific Revolution, including Newton --- the very people who founded modern science and showed that the universe follows mathematical laws --- were devoutly religious and believed in miracles.
1.. Peter Harrison, "Laws of Nature in Seventeenth-Century England: From Cambridge Platonism to Newtonianism", in The Divine Order, the Human Order, and the Order of Nature: Historical Perspectives, Eric Watkins (ed.) (Oxford University Press, 2013), pages 127-148.
2.. “God and Cosmic Order”, Stephen M. Barr, Society of Catholic Scientists website, Monthly Article, September 2020. https://www.catholicscientists.org/idea/evidence-of-god
Resources for further study
The War That Never Was: Evolution and Christian Theology, Kenneth W. Kemp (Cascade Books, 2020), pages 6-13.
Science and Religion. Lawrence Principe. The Great Courses, 2006. Lecture 4.
Faith, Science, and Reason: Theology on the Cutting Edge (2nd edition), Christopher T. Baglow (Midwest Theological Forum, 2019), Chapter 6.