Our main breathing muscle is the diaphragm, a dome shaped muscle under the rib cage. When we breathe in, the diaphragm flattens out and pushes on our abdominal contents (stomach, intestines, bladder, etc), sending them down toward our pelvis. At the same time, the abdominal muscles tighten a little bit and the muscles of the pelvic floor, located between your pubic bone and tailbone, lengthen a little bit. This allows us to manage the increase in pressure in our abdomen that occurs when the diaphragm flattens out. When we breathe out, essentially the opposite happens: the diaphragm relaxes and goes back up toward the heart, the organs move up as well and the pelvic floor muscles contract.
Now if you have to cough or shout - something that requires us to breathe out forcefully, the abdominal muscles are going to contract more forcefully. This increases the pressure in our abdomen a lot. The pelvic floor muscles now have to contract a lot as well, to help prevent things from being pushed down.
For people that have issues with continence, it is often this coordinated movement that is disrupted. Muscles may be too tight (not relaxing enough) or too weak (not contracting enough).
One place to start to help engage the right muscle pattern is to focus on breathing. Try this exercise: lie on your back with a pillow under your head and one under your knees. Breathe in through your nose gently and feel the rise of your belly. Now exhale gently through your nose. Imagine the up and down motion of the diaphragm and the effects on the organs. Do this a few times. Now bring your awareness to your pelvic floor muscles. As you breathe out, see if you can engage them by squeezing them gently. This would be the same as stopping the flow of urine when going to the bathroom (do NOT do that as an exercise). The key is to not only contract when you exhale, but also relax when you inhale. As this gets easier to do, practice in a variety of positions.
And the next time you really, really need to go, but are still a few minutes away from the bathroom, focus on breathing out and contracting your pelvic floor muscles. Trust me, it will help a lot more than holding your breath or breathing in!