The electroweak unification works despite electromagnetism having infinite range and the weak force having almost none, because the photon (electromagnetism's force carrier) is massless while the W and Z particles (the weak force's carriers) have mass.
Don Lincoln explains that electroweak unification is reconciled with electromagnetism's infinite range and the weak force's tiny range by the mass difference between their force-carrying particles: the massless photon versus the massive W and Z bosons.
transcript
Don Lincoln: electroweak force is real. The way we make it so that there is now an electromagnetic force and a weak force is the force-carrying particle of electromagnetism has no mass. The force-carrying particle of the weak force has a mass.