When using an optical mouse, this often occurs when using it on a surface that is shiny and reflective, an sometimes on white glossy surfaces.
Optical mice basically use a small camera to detect movement, and if they can't "see" enough detail or texture detected motion can be erratic, with the pointer jumping around and tracking in jerky movements. With reflective surfaces, the camera sees itself, and chases itself resulting in the pointer heading off in a line to the edge of the screen.