Urine is normally sterile while it is still in the human body (except when you get a urinary tract infection -- a UTI). However, it is a very good media for bacteria, so once it leaves the body, bacteria thrive on it. This is why, if you don't flush after you pee, the water begins to turn cloudy and smell pretty rank after a couple of days (even without fecal matter). After you flush, most likely you'll see a ring of slippery "scum" left on the toilet bowl ... frequently a pink one. I'm not talking about white mineral rings left by hard water or well water iron-colored mineral rings.
Urine contains waste products from the body like creatinine, urea (a source of Nitrogen), uric acid, and other minerals (like Sodium, Potassium, Magnesium, Phosphorus) which are soluble in water as salts. Normally there is minimal Protein and/or Glucose. Bacteria from the environment love these nutrients.
Typical bacteria which may invade the urinary tract are Escherechia coli, Pseudomonas species, and Klebsiella species, and Bacillus species. Staph and Strep may also show up, although UTIs with these bacteria are less common. All of these are common in the environment. You very probably have some of each of them on your skin right now (when was the last time you washed your hands?).
The chemical formula for Ammonia is NH3 ... the 'N' stands for Nitrogen. The bacteria change the Nitrogen salts to ammonia. The urine pH changes from neutral to alkaline. Other bacteria oxidize the ammonia. Some bacteria like cold, some prefer hot temperatures; some prefer acid environments, others prefer alkaline environments.