How does this work wouldn’t the user have to go buy the domain name from a domain registrar?

Yes. This assumes that the user wants to use a domain of their own – they would need to create a CNAME record in the domains DNS zone that points to the application. This is a pretty common concept.