I've had this problem on so many mice over the years, going back to the Amiga days. Often it can be fixed by opening the mouse and gluing a tiny bit of thin card to the nub which presses on the microswitch. (Usually the problem is just that the plastic has worn down over the years and no longer pushes the button quite far enough to make a clean contact.)
I've fixed some of mine by opening the switches themselves and bending the metal spring a bit. Of course that only lasts for so long before you need to re-do the fix.
The middle mouse button seems to be the one to fail the most - I guess manufacturers cheap out on it even more than others since it isn't used by normal people that don't use X11 (middle click paste for selections) or know that it opens links in new tabs (in FF at least).
> This is one more example of perfectly good theory not getting used in practice to save pennies per unit and also to perpetuate planned obsolescence. That is, sales would drop if you no longer needed a new mouse every two to four years as a result of glitchy buttons.
FWIW, the [1]Zaunkoenig brand is where I first heard about this. I have their M1K and M2K mice, which are really nice. (I am otherwise unaffiliated with them)