When magic makes no sense, then every magical solution is deus ex machina, and you never know when a situation is truly dangerous, since it's never clear what poses a challenge to magic.In a sense this is true in science fiction as well as fantasy, and it is what distinguishes true speculative fiction from modern fairy tales, whether they take place in a fantasy universe or a technological universe.
Star Trek was a major offender for inventing new technology either as a plot device or as an unexpected escape mechanism. That's one of the reasons I sometimes say that Star Trek wasn't real science fiction.
Real speculative fiction has consistent and reliable rules for the universe, rules that the reader can rely on. Sometimes you keep learning those rules throughout the story, but they always grow logically. They don't just pop up to rescue an impossible situation.