Mouse wheel scrolls the page down then up, or up then down

Solution 1:

I just switched the number of scroll lines from the default (3) to 5 lines and this seems to have stabilized the erratic behavior.

Solution 2:

It's dust.

No, really: it happened to me many, many times, and the cause so far has always been dust inside the mouse. It gets trapped in the scroll wheel and interferes with the sensors.

In order to solve it, open it and clean the wheel — or, if it's a cheap model, I recommend buying a new one.