The pressure that you apply when you push during a bowel movement derives from an increase in the pressure of the abdomino-pelvic cavity. You generate this pressure by closing the glottis (the opening to the lungs) and contracting the anteriolateral abdominal muscles (i.e., the external oblique, internal oblique, and transversus abdominus). This reduces the volume of the (now sealed) abdominopelvic cavity and increases pressure helping to drive feces from the rectum. This is mechanism is also used to expel urine and during childbirth.
If you do this with the glottis open, then you forcibly exhale because the increased pressure of the abdominopelvic cavity is transferred across the diaphragm and into the thoracic cavity compressing the lungs.