Why are the organs for reproduction and urinary excretion combined?
Developmentally, the urinary and genital systems (typically you will hear them referred to as "urogenital system") are derived from the same embryonic tissue, the intermediate mesoderm. The embryonic kidneys are drained by the mesonephric duct in both females and males. This embryonic tissue also gives rise to the ovaries and testes. The mesonephric duct degenerates in females, and becomes the ductus deferens in males. A second tube, the paramesonephric duct develops in both, but degenerates in males. The female paramesonephric duct becomes the uterine (Fallopian) tube.

Embryonically, the ureter, which drains the adult kidney is connected to the mesonephric duct. This connection is maintained in males, so that both urine and semen share a tube (urethra) for some of their exit pathway. In females, the paramesonephric duct and urethra are separate, so there are two openings.

In males, sphincter muscles and autonomic control prevent the simultaneous expulsion of urine and semen.



This system has worked acceptably well in mammals for at least about 200 million years (and in humans for the last 4 million or so), so I think it's not correct to call it a mistake. It's not how you would consciously design such a system, but evolution doesn't have a conscious designer.

Here are some slides that cover the embryology of the human urogenital system.