Or was there a story that a writer had submitted that had some scary Halloween related elements that they ended up showing during Halloween?
Mostly..but the timing was deliberate.
Information can be found in These Are The Voyages: Season Two by Marc Daniels..
In there he quotes the writer, Robert Bloch..
“They wanted a Halloween story,” Bloch told Starlog magazine in 1986. “I wanted to do something that would involve changes in appearances. So, I decided that instead of having the usual Jekyll-and-Hyde transformation, I’ll have a female who was capable of chameleon-like adaptations. And the rest just fell into place.”
and further...
“Catspaw” aired four days before Halloween, 1967. Talking to this author [Daniels], Dorothy Fontana said, “That was planned all along to be like a Halloween show. When Bob [Bloch] pitched it, we said, ‘That’s got to be the Halloween show for sure!’ I liked it. I thought it was pretty good.”
So basically, it was pitched as a scary story and the producers & other writers grabbed it and made it a Halloween show.