When you cough the diaphragm moves in such a way as to compress the contents of the abdomen. As they are within a fixed volume, pressure rises in the abdomen and to reduce pressure urine can be forced out through the urethra. This can be prevented by exercising pelvic floor muscles which will allow you to voluntarily cut off the exit of the urine when you need to cough...
I have also been known to do this when I sneeze....I just plain accept it...

..Take care...
Caroline