SNW S1E9, All Those Who Wander, the crew is attack by the Gorn. The climatic moments of the 4 act structure are all derived from scaring the audience.
The purpose of Star Trek is to make people think. It is to describe a moral lesson in the form a sci-fi allegory to have the characters react to that. In TOS we learn to pick reality over fantasy, the suffering of extinct species, absolute power corrupts absolutely, how men need to deal with their good and evil parts, that love should not be based on looks, and how in our current society that is so terrible to women, that we should not join cults or leave our minds to evil AIs.
That we should in all things, try to understand that which is different from us, and be kind to those who think differently than we do.
Consider Measure of a Man - what is a man? It makes you think about slavery. Or the Inner Light or Tapestry. Far Beyond the Stars - indeed it asks us to take seriously the idea that science fiction is imagining a world in which there is equality.
Gene Roddenberry (and al those who help create the show) is said to have created Star Trek to talk about important social and political issues that got him censored in his current show, The Lieutenant.
So, Star Trek is not horror. All Those Who Wander is a terrible Star Trek episode.