You can say this about the bulk of fantasy settings where magic is explained via consistent in-universe laws.
Except in those settings, it's supposed to be actual magic, something based in the supernatural or divine.
Star Trek, again, is a Clarke's Third Law setting: anything indistinguishable from magic is merely sufficiently advanced technology, or physics we don't yet understand.
Trelane being able to change his appearance, freeze people, and move the planet to chase the ship because he has a special mirror isn't functionally different from a mage being able to cast illusion spells because they have a special amulet that channels ley energy.
That's conflating in-universe and metatextual analysis. Metatextually, yes, they essentially work the same as narrative devices. But in-universe, there is a fundamental difference between a universe that says real magic and divinity exist and one that says there is only advanced science and technology that humans can eventually understand.
Gene Roddenberry was a humanist. He wanted
Star Trek's message to be that there was nothing that the human mind could not understand or achieve with sufficient knowledge and persistence. So one of the basic rules of Trek is that everything has a scientific explanation, that any pretense of magic or divinity is merely alien roleplaying.
For that matter, the censorship of the era means that even creators who
wanted their universes to be more magical or divine weren't always able to.
Battlestar Galactica was a space-opera interpretation of the Book of Mormon, but it had to handwave its equivalent of angels and demons as highly evolved aliens with seemingly godlike powers. In the same way,
Doctor Who traditionally has the Doctor insist that anything that appears to be magic is merely science humans haven't learned yet, although the modern shows have sometimes ignored that.
Similarly, Apollo isn't meaningfully different from the gods and goddesses in, say, Xena or The Elder Scrolls, in that both are advanced lifeforms with superhuman powers with in-universe metaphysical explanations
Incorrect. Apollo has an in-universe
physical explanation, i.e. he's an advanced alien with a special energy-channeling organ, and his people were space travelers who settled on Earth and only
pretended to be gods. He also had physical limitations that divine beings did not. The gods in
Hercules/Xena could only be killed by special divine weapons. Apollo was weakened by a phaser barrage.
Even space travel itself - the Enterprise and its (inconsistently-portrayed) warp drive aren't any more scientifically grounded than a Spelljammer in any way I can see, beyond that the aesthetics of Spelljammers are obviously meant to look more fanciful.
Hardly. The very term "warp" comes directly from the General Theory of Relativity. Einstein himself and his collaborators theorized ways that the topography of spacetime could be altered, i.e. "warped," to allow cosmic shortcuts that were effectively faster than light, such as an Einstein-Rosen bridge (wormhole). The concept of space warp propulsion based on this principle was featured in science fiction from the 1930s onward, and is seriously studied by theoretical physicists today.
Most SFTV of the '50s-'70s assumed that you could travel between star systems or "galaxies" with conventional rockets.
Lost in Space paid lip service to hyperdrive once or twice but mostly showed the ship drifting between planets through conventional space.
Space: 1999 had the Moon drifting from star system to star system without explanation, with occasional handwave references to space warps.
Battlestar Galactica claimed that the ragtag fugitive fleet was able to traverse multiple "galaxies" within a year while traveling at a
maximum of the speed of light (and depicted adjacent "galaxies" as having no separation between them, like crossing a state line). Just acknowledging that warp drive would be necessary at all, and understanding what a galaxy even
is, put TOS far ahead of the competition in scientific literacy.
And it goes beyond that, since Roddenberry's scientific consultants informed him that a warp drive would require matter-antimatter annihilation, the only power source strong enough, and that a fast-moving starship would require a navigational deflector dish to repel space debris. They didn't just make up a bunch of empty nonsense.
I have a hard time thinking of many fantasy settings that portray religious belief as objectively true; "gods" being killed, corrupted, or destroyed through physical means - thus proving them to be essentially advanced non-human lifeforms - is an extremely common trope, as is the ability for normal people to undergo apotheosis with the correct technology.
That doesn't follow at all. Different religions around the world have many ways of defining divinity, and they don't all require immortality. I mean, look at Set killing Osiris in Egyptian mythology, or the Japanese goddess of creation Izanami dying in childbirth. Or, heck, Christ being killed and resurrected. The death of a god, often followed by resurrection, is often an important part of their mythology.
The script could obviously say "well, these ghosts are lifeforms with material explanations", but again, a great many fantasy settings already do exactly that.
If a story postulates a scientific explanation, then by definition it isn't fantasy. Yes, there are fantasy universes whose magic can be studied and understood, but it's still magic power that doesn't exist in our universe. The pretense of science fiction stories is that their phenomena do exist in our universe even if we haven't discovered them yet.