UX design involves identifying a pain point or user need, then drawing up and validating a prototype through user testing. Once both the value proposition and user needs have been validated, the product is built.
It isn’t until after all of this (usually) that the UI designer comes in.
A UI designer works with the initial prototypes set up by the UX designer to include visual elements that make the product beautiful and memorable.