Kinda depends on what the magic system is for--in Alchemist Burnouts I made it very simple. I wanted the story to revolve around different parts of America and feel like it's magic has roots in american folklore. So the magic systems were already there for me. Alchemy is sort of self-explanatory, messing with luck and fate is also kind of self explanatory, and channeling the power of an animal is also...self-explanatory. And so to balance out all these systems (because there's just a lot of different types of magic) I just made sure that there was a rock-paper-scissors method so no one system could stay on top.
But since Alchemist Burn Outs is a coming of age story, the magic takes a back seat in a big way. I'm sure if you thought it about it too long you'd realize it's a pretty shallow magic system, but it's sort of unimportant because the book is...about growing up.
But other stories I've written that were more high fantasy, my magic was based on things that went along with the theme of the story. So Avu is a cat comic (that I will never have time to continue) but it's about going extinct. So I got inspired a lot by astronomy and how the stars we see aren't actually there and are already dead--so there's a lot of references to stars in the magic system. Most of the spells have been forgotten (so I don't have to write them) and the only ones left seem to have very little purpose. (but I, the author, knows their purpose, and the whole story is the mystery of figuring all that out) A lot of the ancient text they have is written with star patterns that the modern people can't read. Little things like that.
And then when I wrote the current story I'm writing now I wanted the theme to be about abusive relationships, not just as romantic relationships but also between nations and organizations. Exploring that theme sent me towards psychology and history as inspiration for the magic system and how it works. So I decided to make the goal of my magic system to be "rewriting history" since that's one of the most powerful tools that an abusive person uses. Once I knew that was my goal, I was able to form the rest of the magic system over the course of writing the story (there's still stuff I haven't fully figured out. Even now. I'll get there eventually.)
But I find that even not science stuff can be inspiring for magic system. Like I was watching AGDQ one year and they did this skip in Ocarina of Time that involved a ton of steps to make Zelda's Letter appear in a box where it shouldn't be, and doing that could call anything in the game to appear in their inventory. It was wild, and I was like...damn that would be a great magic system for a fantasy. To make a letter so powerful that it could just give you anything in the world. I don't think I'll ever write that story, which is why I'm like...propping it out here. But magic doesn't have to be just based on science or math. It could be anything.