When I absolutely can't avoid it, these are the things I do:
1. In long travels or overseas flights, I would buy toilet seat covers in advance for my kids (specifically, the ones below). They fold flat and small. They cover the entire seat and then some. So when they swing their legs, their thighs won't touch the seat at all. I just fold it up and throw it in the trash.
2. I have an antibacterial spray for our hands in case the restroom is out of soap.
3. If we were on our own and I need to use the restroom, I tell my kids to stick a foot under the doorway so I can see them at all times. My daughter tends to sing. She said, so I know it is her foot and that she is still there.
4. With infants: I always buy a stroller that folds completely flat so I can just change him on there. If I need to use the changing table, I bring the Goodnights pad (for the bed). It completely covers the table.