Prostatectomy is primarily performed to treat localized prostate cancer that has not spread beyond the prostate gland. It is also used for treating severe symptoms of BPH, such as urinary retention or recurrent urinary tract infections. In some cases, it may be recommended to relieve pain caused by advanced prostate cancer.