Sitting on the toilet in a public restroom, almost finished, when suddenly the automatic sensor decides to flush itself too soon, and splashes everywhere.

It's a startling experience to say the least, as well as unsanitary and undignified; certainly something that I don't want to repeat if I have anything to say about it.
(In the worst cases, I personally have experienced one such toilet deciding to flush four whole times before I was ready! Talk about rude.)

The question, then, is this:

Is there any explanation for why this happens, and more importantly, is there any way that I can consistently prevent it from happening to me?

I just experimented with this toilet-paper method, and it does seem to work, but not necessarily in the way one might expect! If the toilet paper is wrapped directly over the sensor with no air gap in between, then the toilet might never realize that you were there in the first place. All things considered, this still seems to be the best option if a wardrobe change is out of the question (lol); one must take care to ensure that the toilet does in fact flush when you're done, however, or you might end up leaving an unpleasant surprise for the next person.
– RobotZombieLordMar 5 '15 at 22:46

Well, what I do is make sure light shines directly onto the sensor, then quickly cover with the toilet paper and leave it. No light can go to the sensor otherwise you must start over again. Then remove when done. This emulates sitting in front of the sensor which is what they're designed to recognize.
– subjectivistMar 6 '15 at 1:24

At a fundamental level, automatic toilet flushers generally use infrared light as their cue to determine whether or not there is someone currently sitting in front of them. They don't just see ambient infrared light, however; instead, they shine an infrared LED at you to ensure that there is always plenty of "illumination" for their sensor to work with.

As it turns out, then, this means that there are two factors to worry about...

Reflectivity of "target"

This was my first observation: when I wore clothing that absorbed more light, then the sensor had more difficulty tracking me. Deeply textured, dark fabrics are the most likely to cause an issue; smooth, light-colored fabrics are consistently fine.

Distance to sensor

Moving closer to the sensor is just like moving a flashlight closer to a wall; the reflected light looks brighter and brighter, because it's concentrated into a smaller and smaller area. This continues right up until the flashlight is touching the wall, at which point you can no longer see any reflected light because the flashlight itself blocks your view! It actually turns out that the same principle applies to automatic toilet flushers, because an object touching the sensor is invisible to the sensor.

Example

My favorite vest was black, fuzzy, and loose fitting. This meant that the sensor already had difficulty tracking me, but it could make do as long as I didn't violate the distance rule.

Whenever I leaned forward too far, the reflected light wouldn't be bright enough; the sensor thought I had stepped away, and so the toilet would flush.

Whenever I leaned back, the vest would swing back even further; whenever the vest touched the sensor, it thought I had disappeared completely, and so the toilet would flush yet again.

Solutions

I tested three solutions, which were all equally effective:

Ensure that my outermost layer of clothing was not black & fuzzy;

Ensure that I never allowed any part of my clothing to touch the sensor;

And finally, Subjectivist's solution with the toilet paper also did the job equally well.

Theoretically, one could also solve the problem by always sitting bolt upright and being very careful not to move... but somehow, that option never appealed to me. (lol)

The sensor on an automatic flush toilet uses the same principle as a motion detector. The two sensors detect body heat (infra red) in close proximity. If the signals are the same nothing happens. If you remain still the sensors don't react. When you move one sensor detects a change and triggers the flush mechanism.

Ambient temp also affects these devices as well.If the room is extremely hot these devices don't function well at all and won't flush. In cooler rooms these devices react very fast because of a greater differential in temp.