UNIX came first. It was made for big computers. I mean mainframes, MInis, that sort of thing. AT&T had the patent on it.
There are various versions of UNIX customized for different computers. HP minis run HP-UX, and Santa Cruz Operations had Xenix for the x86 machines. There's bazillion other versions. They all cost $$$$.
Then came Linus Torvald, who decided to write a version of UNIX for x86, and he decided to crowd-source it (back then, it was a revolutionary concept) but he wrote the core of it, the first version. He called it Linux.
So Linux is UNIX, for x86, with some small changes.