u must be having a problem with your prostate , you need to see a doctor.
the prostate works in a way , that when your turned on , it gets bigger and blocks the stream of the urinary cannel , when your done masturbating its shrinks to its normal size.
It is possible for a man to urinate when he has an erection. I recommend completely emptying your bladder before you masturbate. If this still happens your inner urethral spinchter may be weak and not shutting off during your orgasm but it that is the case you would not see any semen. So, do you ejaculate normally? If so, I would say that is not a problem and just make sure your bladder is empty before you masturbate.