It isn’t a problem with your urinary system. Rather, it’s nervousness about peeing when you’re around other people. It’s considered a social anxiety disorder. Anxiety fills a part of your nervous system with adrenaline, and the muscles that let you empty your bladder just freeze up.
Maybe it started when your parents criticized you during potty training, or in school when someone bullied you or made fun of you in the restroom. Or it could have happened at the doctor’s office, when you couldn’t pee on cue for a urine sample. At worst, it could relate to sexual abuse that happened in a restroom.