There are several possible causes for this issue. Take each of the following steps until it's resolved.
1. Follow the instructions in this support article,
and also this one,
2. Open the Bluetooth preference pane in System Preferences and check for unknown or forgotten input devices. Disconnect any USB input devices that you aren't using.
3. Boot in safe mode Here's how: http://support.apple.com/kb/ht1455
and test, preferably without launching any third-party applications. If you don't have the problem in safe mode, but it comes back when you reboot as usual, stop here and post your results. If you can't boot in safe mode, do the same. If you booted in safe mode and there was no change, go on to the next step.
4. Reset the System Management Controller.
5. If you're using a Bluetooth trackpad, investigate potential sources of interference, including USB 3 devices.
6. A swollen battery in a MacBook Pro or Air can impinge on the trackpad from below and cause erratic behavior. If you have trouble clicking the trackpad, this is likely the reason. The battery must be replaced without delay.
7. Some people have reported that they fixed a malfunctioning trackpad by pressing down on all four corners at once. I can't confirm, but it does no harm to try.
8. There's a report that a (possibly defective) Thunderbolt Ethernet adapter can cause the built-in trackpad of a MacBook to behave erratically. If you're using such an adapter, disconnect it and test.
9. There's also a report of erratic cursor movements caused by an external display that was connected but not turned on.
10. If none of the above applies, or if you have another reason to think that your computer is being remotely controlled, remove it from the network by turning off Wi-Fi (or your Wi-Fi access point), disconnecting from a Bluetooth network link, and unplugging the Ethernet cable or USB modem, whichever is applicable. If the cursor movements stop at once, you should suspect an intrusion.
11. Make a "Genius" appointment at an Apple Store to have the machine and/or external trackpad tested.