The typical toilet tank will have a flapper which seals the water in the tank. When you flush the toilet, the flapper is lifted and water is allowed to move from the tank into the bowl. Once a set amount of water has exited the tank, the flapper falls back down and re-seals the tank.
The most common issue with toilets randomly flushing is that the flapper has become brittle or sediment has formed on the flapper/tank which prevents the flapper making a complete seal. This will allow water to slowly drip from the tank into the bowl. If enough water is permitted to leak out of the tank, the filling mechanism will be triggered and the tank will refill. If enough water enters the toilet bowl, the self-siphonage will be triggered and the bowl will drain into the sewage system.
Here's a picture of a typical assembly: