This happens to me WAY more often than it should. Do you ever accidentally make eye contact with someone who is sitting in a toilet stall? You know, through that little crack between the door and partition?
I think it happens because I just want to see if someone is using it, and it seems less awkward to do a superficial and quick glance to see a dark shadow or something than the bend down to look at their shoes.
Here is what I propose: if you're in a stall, never look out through the crack. This will avoid me having to decide whether to acknowledge the fact that I made eye contact with you while you're doing your business.