Hi,
Possible causes of urinary retention can be broadly divided into outflow versus bladder conditions.
Outflow obstructions
For males, this is usually caused by an enlarged prostate. Other causes can be due to narrowing of the urethra due to scar formation (stricture) or obstruction by a stone.
For females, outflow obstruction also can be caused by narrowing of the urethra due to scar formation (stricture), obstruction by a stone, or other mass lesions.
Bladder conditions
If there are no outflow obstructions, urinary retention can be caused by a simple urinary tract infection or more complex due to weakness of the bladder wall.
Weakness of the bladder wall can be due to damage of nerve supply to the bladder in conditions such as spinal cord injuries, post-stroke, brain tumour, or diabetes mellitus.
I would recommend that you get a full assessment by a specialist urologist as sudden onset of urinary retention is not normal.