This is why our bathroom had a deadbolt lock when I was a kid.
Not to use a as a panic room in case of burglars.
Not to force children to wait until you're done.
To keep DOGS out of the bathroom.
My mom has a shy bladder, and she flatly CANNOT go if there's anyone else in the bathroom--dogs included. Our little chia-rat dogs were easily held out by the simple latching of the door. They didn't much like being left out of the action, but didn't really have any choice.
Then my uncle got Daisy, his infamous turkey stealing Saint mix. By the time she was 6 months old she figured out how to grab a door handle in her mouth and turn it to open a door. Needless to say, she went pretty much everywhere she wanted to, and it didn't much matter whose house she was in.
After she'd traumatized my poor mother twice, Mom made Dad go buy one of those storm door hook and eye latches.
That didn't even work one time.
Daisy got the door unlatched, but found it would only open an inch. Those latches might stand up to a 5 year old, but not a 6 month old Saint with her feet braced against the wall. She flat SHOVED the door open with her head, and ripped the hook piece right out of the door frame.
It's good to be reminded of the need for a deadbolt for the bathroom door when you have a big paw...