Next time you are out at Home Depot or Lowes they have those special keys just for those bathroom doors. I'd suggest to pick one up and put it over your door jam or somewhere you can get to it next time this sort of thing happens.
Oh and for the time being to keep your baby calm...if you can look underneath the door you can push some kibbles of the dog food under the door and make it like a game while you are talking to them...my dogs love that game.