I don't have an answer that is, "this is your problem and I know what is going on." It's more of an "it sounds like..." answer.
Honestly it sounds like there is an external mouse or other USB device which is (for lack of a better word) misbehaving. Which brings up the prime directive of troubleshooting, Isolate And Identify.
Unplug everything (drives, power, monitors, everything!). Do you still have the problem? If not blame something you just unplugged, if the problem still exists then finding the issue becomes more problematic.
Start in Safe Mode. Boot the Mac while holding the Shift Key. You can release the key when you see the Apple logo. Booting will take a longer time. Once you are logged in, does the issue still happen?
- If not then there is software installed on your Mac that is causing the issue.
- If so then it is likely/possible it is a hardware issue.
If it is number 2 (from above) Then you will need to take it into an Apple Store or other Apple hardware tech and see if they can find the issue. In a situation like this it is logical to suspect the trackpad and/or the keyboard. But it is impossible to tell from this side of your screen.
Feel free to edit your original question to the answers to these questions and we can help as best we can with more troubleshooting.