The Nissan Leaf is using a different (less efficient) electric motor tech (DC Brushless vs AC Induction), has different aero properties, different regen capabilities, single motor, tyres, etc. The higher efficiency of the S reflects a lot of attention to detail accumulating into a whole.
The M3...