It's probably because you can only have one pathway open at a time. For pee or sperm. When your hard, its open for sperm so thats why it's so difficult to pee. When you start peeing, it closes the sperm way and opens for the urine. If they were always open together your urine would kill the sperm making it sterile or you'd get infections.
There is definitely something in this, except that the switch from pee mode to sperm mode doesn't necessarily happen immediately we get hard, though it may differ from one person to another, i.e. just how aroused we need to get, and possibly due to the reason for getting hard.
With morning wood, the reason may not be sexual and the problem may not be so much that it is impossible to pee but that an erection doesn't want to point downward towards the toilet bowl. One can either wait for it to go down, or go the route of standing in the shower where is doesn't matter much where it is pointing. At least that's my experience.
So back to this dual mode plumbing, it may help to refer to an anatomical drawing here, but if we follow the urethra (tube) downstream from the bladder to the penis it goes first through the upper (internal) sphincter, then through the prostate gland, then through the lower (external) sphincter, past the bulbouretral glands and finally up the inside of the penis to the tip.
The part through the prostate gland is not only where the prostate glands adds it's own contribution to our semen but the sperm and the liquid from the seminal vesicles are also added here, so essentially amost the whole of what we ejaculate.
Now the upper sphincter is involuntary, i.e. we don't conciously control it. Normally, it is closed, except when we need to pee, when it is open, unless that is overridden by being aroused and preparing to cum when it is once again closed.
The lower sphincter is voluntary, i.e. we can conciously control it and that is how we can avoid wetting ourselves once we need to go but are delaying to find a toilet.
So when anything is coming out of our penis the lower sphincter must be open. When we're peeing the upper one is open but when we're cumming the upper one is closed. That means all the liquid delivered into the prostatic part of urethra has to go downstream and out of the penis and not upstream into the bladder.