For a person to be able to urinate, there must be no obstruction to the bladder outlet and the bladder muscle must be able to contract to allow the urine to be drained from the bladder. At the same time, the sphincter (the muscle that maintains continence) has to relax as the bladder contracts.
The most common cause of urinary retention would be an obstruction to the bladder outlet eg due to an enlarged prostate in men, stricture (narrowing) along the urethra. A stone wedged in the urethra can also cause an obstruction and hence result in urinary retention. These are usually patients who present with acute urinary retention with lower abdominal discomfort.
Other less common causes would be neurological conditions (eg spinal cord injuries, stroke) that cause weak contractions of the bladder muscle or inability of the sphincter to relax or even lack of coordination between bladder contraction and sphincter relaxation.
These patients tend to have chronic urinary retention (less likely to have abdominal pain) and are more prone to kidney failure as the pressures build up from the bladder and are transmitted back to the kidneys.
Urinary retention needs to be evaluated and the aim of treatment is to maintain good function of the bladder (both as a storage organ for urine as well as a good voiding organ for urination) and to prevent kidney failure.