I have a friend who spent many years in the U.S. navy as a submariner until he retired.
In submarines nowadays the toliets flush into a storgae tank system....never directly outside.
But still there are vent tanks.
When you are at depth the pressure OUTSIDE is often greater than the pressure in the toilets inside.
In the old subs the toilet lid had a locking mechanisim on the toilet lid.
In those subs you NEVER flushed a toilet without first closing and locking the lid.
If you did the toilet might flush upwards.....and that was nasty.
It only took one mistake to make you learn to never flush without closing and locking down the toliet lid.