Cystoscopy is performed to diagnose and treat various urological conditions, including urinary tract infections, bladder stones, tumors, urethral strictures, and hematuria (blood in the urine).