There are certain sci-fi plot devices that are hard to distinguish from supernatural stories. STAR TREK veered into this territory all the time.
In The Cage, the Talosians create illusions that might as well be spells they cast.
In WNM, Gary Mitchell and Elizabeth Dehner gain powers that are a lot like magic. An alternate interpretation is to say they were possessed. But since Dehner wasn't possessed by an evil force, it seems that Mitchell was just a bad guy waiting to happen.
What about Charlie X, and the somewhat similar case of Captain Garth in Whom Gods Destroy? Somebody taught them magic.
Catspaw was made expressly as a Halloween episode to air in October, and it calls the witches by name. The themes include both possession and magic.
Wolf in the Fold (SPOILER ALERT) is a demonic possession story that goes all the way into horror. Scotty is possessed and he murders two women. This being TV, once the explanation comes out, all is forgiven. It's an incredibly lucky outcome for Scotty, what with all the blood on his hands.
Or did the demon stay in Mr Hengist the whole time, and just cause Scotty to black out? That sanitizes Scotty, but Act IV clearly shows the demon's ability to jump from person to person. Why not
possess Scotty to kill the women? Poor Mr Hengist from Rigel IV, who's just another victim of possession, is holding the bag when Kirk needs to kill the demon. That's an unlucky guy, and his death is not memorialized in the slightest.
The Lights of Zetar is another possession story, with a ghost angle, and it could have been a lot scarier if they'd wanted it to be. Like (and I shouldn't say this), if JJ Abrams remade it as a horror film, it could creep the crap out of people. But the TV version was pretty mild.