Why take medications for epilepsy if I can just have surgery instead?

Depends. Epilepsy surgery is an excellent option for those with uncontrolled (two different medication trials) partial epilepsy coming from a single area of the brain, when that area is not involved in important brain function. Easily controlled partial seizures or those with primary generalized epilepsy are usually treated with medication.
Risks. If your medications are properly controlling your epilepsy, you are best taking medications for life. The reason for this is that not all surgery patients are seizure free after surgery and hence ~15-20% (or more in some seizures types) of patients after surgery will still require medications therapy. Hence, if meds are controlling your seizures then keep taking them and forego surgery.
Not exclusive. As a rule, medications need to be tried before surgery is used to treat epilepsy. Surgery may be curative in some patients, but is an aggressive approach that should be considered very carefully. Many patients find that a single medication is quite effective for control, and surgery is not necessary. For others, failure of two medications would justify the consideration of surgery.