Certificates may have more than one name – X.509 v3 supports an extension called "Subject Alternative Name" or "subjectAltName". This extension contains a list of names, e.g. in this case:
In TLS, if this extension contains any DNS names or IP addresses, the certificate is valid for all of those names – and additionally it completely overrides the primary subject "CN" field.
In fact, the major web browsers have decided to require subjectAltName and completely ignore the subject "CN" (although only for commercial WebPKI certificates, not internal ones). It is likely that in the future WebPKI certificates will no longer have a CN field at all.
(One of the reasons for this switchover is that practically all systems support SAN, so the CN is practically never relevant anymore. Another is that subjectAltNames are strongly typed (each item is marked as a DNS domain, or an email address, or an IP address...) whereas the regular subject CN is freeform text and its meaning is system-dependent.)