This is a little complicated, but: The main advantages of mechanical pattern switching result from the related facts that (a) the capsule can be constructed with a single diaphragm rather than two, and that (b) the omnidirectional setting of the capsule can be a pure pressure transducer, rather than the sum of two back-to-back pressure-gradient transducers.
Those things in themselves may not tell you much. The easier one to explain is the second one. A pressure transducer can have flat response down to any frequency you care to name--definitely below 20 Hz if that's what you want. (The practical limit is set by the need to ship or transport a capsule by air without having the diaphragm rupture; practical, working pressure transducers all have tiny pressure-equalizing vents, which set the limit on their low-frequency response.) Pressure transducers are inherently more immune than pressure-gradient transducers to wind noise, breath noise (if you're close-miking a singer or a speaking voice), and handling noise or other solid-borne sound. Also, they have no proximity effect (the tendency of directional microphones to emphasize the low and low-mid frequencies for point or near-point sound sources in their vicinity, as compared with similar sound sources farther away). So there are both audible and practical advantages for people who use omnidirectional microphones, whether they're switchable-pattern or not.
The advantages of a single-diaphragm construction are also audible in cardioids. Two diaphragms can't exist at the same point in space, but the whole way that a pressure-gradient cardioid capsule works is based on the assumption that the capsule assembly has zero thickness. I don't want to attack anyone's capsule designs, but there's one model of dual-diaphragm capsule from a prominent manufacturer which they use in several of their microphones, that has a greater-than-usual distance between the front diaphragm and the back diaphragm--it's a "thick" design, like a small cylinder. At and around the upper midrange frequency whose half-wavelength corresponds to the distance around the capsule's periphery, there are audible ripples in its frequency response. In that respect a thinner (front to back) design would give better results, all other things being equal.
The polar response of dual-diaphragm cardioids tends to "spread out" at lower frequencies--they become more like wide cardioids. (Many, though not all, also become narrower at high frequencies, such as the famous Neumann U 47 and its successors.) The widening of the low-frequency pattern can be a real advantage in a studio setting, because the microphone tends to pick up more low frequency energy from the room than would be the case if its pattern remained truly cardioid. But it's a big disadvantage in coincident or near-coincident stereo recording with cardioids. The wider the pickup pattern becomes, the more the two microphones will tend to pick up identical (or "highly correlated") signals in both channels, i.e. the more the recording tends toward being mono. But it's at low frequencies where you really need "difference information" between your channels in order to have a sense of spaciousness in a stereo recording. So for the kind of two-microphone recording that most people here are into, single-diaphragm cardioids are definitely better than dual-diaphragm cardioids (which, unfortunately, are the type generally found in switchable-pattern stereo microphones).
The main advantage of electrical switching, on the other hand, is that potentially any directional pattern on the entire spectrum can be chosen, from (admittedly fake) omni through wide cardioid and cardioid, to supercardioid, hypercardioid and figure-8. Again potentially, every other possible point in between should be available, whether the resulting patterns have names or not. And there is also the possibility of switching patterns remotely (from the power supply at some distance down the cable). But it's actually rather rare for microphones to take full advantage of this flexibility--not many microphones have continuously variable pickup patterns or remote pattern switching. 90% or more of the available dual-diaphragm, multi-pattern microphones have three patterns (pseudo-omni, cardioid and figure-8) which are set at the microphone itself--and three patterns is also the most I've ever heard of anyone building into a mechanically-switched capsule. So this potential advantage exists, but is rarely made available to the user.
--best regards