Short answer: measure the space you want filled, not the vanity width — mirrors are usually meant to sit within the wall space, not edge to edge on the counter, and that's where most sizing mistakes happen.
The most common mistake
Assuming the mirror should match the vanity width exactly. In most bathrooms, leaving a few inches of wall visible on each side looks more intentional and balanced than an edge-to-edge fit.
What to measure
Width and height of the available wall space, plus the distance to any light fixtures or outlets the mirror needs to clear. Note any outlets or switches that might interfere with mounting hardware.