Horror and science fiction are fundamentally different, of course.
Horror takes a fearful approach toward the unknown, whereas science fiction generally depicts the unknown more optimistically. (Or at least, as something that humankind can overcome through the very human power of reason.)
This is the key difference. There are spaceships in the movie Alien, but Alien views extraterrestrial contact as fundamentally frightening. The tone, the mood, and the horrified reactions of the protagonists in Alien all scream ‘horror movie!’ There is very little of the calm, “We can handle this” attitude that one sees in classic science fiction like Star Trek.
Nevertheless, there was horror before there was science fiction. And as the article hyperlinked below explains, the earliest works of science fiction were arguably derived from the horror genre:
Frankenstein’s monster stands alongside the sharp-toothed Dracula as one of literature’s most iconic figures. His gruesome visage has appeared in numerous popular representations and is a Halloween mainstay. So popular is the image of the shambling monster with metal bolts in his neck that it has all but broken away from its original incarnation in Mary Shelley’s seminal work…Yet ‘Frankenstein’ remains not only a pillar of the horror genre but one of the earliest works of science fiction and a fantastic reflection on the suffering of existence.