Fantasy settings commonly have a magic system of some sort. It is often well-thought out and organised and more-or-less reliable. I’ve heard of authors writing themselves a “bible” about how it is supposed to work so that they don’t make mistakes.
Most of the magic in Harry Potter is reliable and repeatable, for example. Harry’s trademark Expelliarmus always fires. Fred and George’s joke candies always work. Yet the need to practice and perfect it is mentioned a lot of the time (it is a school, remember). And we also see the edges of an organised study of what magic can do. A major section of The Ministry Of Magic is for research, after all. And Dumbledore frequently talks about what they don’t know magic can do when talking to Harry about Voldemort.
The magic in most Dungeon and Dragons settings is reliable, too. I think this is because the settings inherit a game system because players use magic very frequently, either explicitly (like if they’re a wizard) or implicitly (a weapon or even a skill). Adding a reliability check to all magic in DnD would slow things down a lot. In the novels, it is common for a master thief to have an arsenal of magic objects, and they almost always function as designed.
There are sometimes multiple magic systems. Lyndon Hardy did this with his novel The Master Of Five Magics. Each is separate and a major piece of the world economy is built around them. In fact, a major industry is built around training for each magic. The whole story is about someone who sets about being trained in all of them, which is unheard of. With so many magic systems, Hardy created a structure for them all, and rules for each of them. He did this so well that with his sequel, The Secret Of The Sixth Magic, he could create a meta-magic system that describes how they could be changed. Both novels have been praised for creating such an organised description of magic.
The magic in Terry Pratchett’s Discworld is more than a bit organised, too. The wizards of Unseen University are a lot more like scientists than practitioners of nefarious arts. In the later novels, we have everyday devices powered by magical means: cameras and personal organisers are the visible two Pratchett has fun with. Each have a tiny demon running things inside them and they are mass-market products. This magical-being approach is even lampshaded right in the first novel when Rincewind is given Twoflower’s camera to operate. He knows that there are certain chemicals that react to light and he begins wondering how to get from there to a functioning camera. At that point, the tiny demon inside Twoflower’s camera opens the access hatch for the first time to tell him that he’s run out of pink paint.
Pratchett even lampshades this in the large with four whole books that he co-authored with two scientist friends, beginning with The Science Of Discworld. These use the fictive construct of the wizards and their world to explore the sciences of our own world. And I mean “sciences” in a very broad sense of the word. Early excursions look at nuclear physics and cosmology, but later ones look at social sciences like narrative history, and how belief shapes our thinking.
This takes us back to where magic exists in our own history. And that is usually spirituality and religious practice. I know enough about both to recognise that neither are treated very much like science, though.
Praying to a deity is common in both the real world and in fantasy settings. In most fantasy settings, it is often like a magic spell: you say the right words and the deity automatically grants the supernatural effect you’re seeking. Except when they don’t because the plot requires it. And this also doesn’t work in the real world, either. It would be news all around the world if a Catholic Cardinal in the Vatican could reliably and repeatedly summon a fireball by prayer.
One of the allures of fantasy novels is, of course, reading the characters doing the impossible. Particularly in an analogue of our own world. This is one reason the Harry Potter novels are so popular. Who wouldn’t want to be able to wield magic with a simple stick of wood in their home or workplace? Except if lots of other people have one, too. And Hogwarts does teach a lot of offensive magic.
There are some fantasy worlds where magic is rare. I built one for a gaming campaign, yet only one player really grasped what that meant for playing. It was at least three sessions before they had access to magical healing, for instance. Settings where prayers (usually) don’t do anything, yet those who pray think they do are also rare. The Dragonlance novels had a period where that was the case. This was because the gods had deserted the world for a period of time, and people were calling to new gods that did not actually exist.
So how reliable is the magic in your fantasy worlds?