I think of urine and bacteria as similar to the fermentation of yogurt, and that helps me understand it.
The urine is "pure" while in the bladder.
When it comes out it is contaminated by small numbers of bacteria in the urethra.
They grow initially and participate in the "fermentation" process to old urine.
So at one point, several hours into the process, the urine is quite filled with bacteria.
But just like yogurt--which when fully "soured" the lactobacilli will actually die off from the acids they produce--when the urine is fully fermented, the bacteria that were involved will be killed by the ammonia.
I did some reading on this on wiki and googlescholar and this is now how I understand it.