Urine contains water, urea, electrolytes, and waste products. When exposed to air, bacteria break down urea into ammonia, which causes the characteristic smell. Longer exposure to air leads to more ammonia production and a stronger odor.