This study aimed to investigate the impact of aflibercept and dexamethasone (DEX) on the formation of epiretinal membrane (ERM) and their treatment outcomes in eyes with diabetic macular edema (DME). In this retrospective cohort study, medical records of 124 eyes from 429 patients diagnosed with DME were reviewed between June 2017 and June 2019. Patients were categorized into two groups: the aflibercept group (67 eyes) and the DEX group (57 eyes). The primary endpoint was the secondary ERM incidence following intravitreal treatments and its correlation across different medications. Secondary endpoints included longitudinal changes in best-corrected visual acuity (BCVA) and central macular thickness (CMT). Over a 24-month follow-up, eyes treated with DEX had approximately a fourfold higher incidence of ERM development compared to aflibercept [hazard ratio (HR) = 3.97, p = 0.02]. These eyes also showed worse BCVA (p = 0.059) and increased CMT (p = 0.004), despite requiring fewer total injections (p = 0.000) in the survival analysis model. The cumulative probability of ERM formation was 13.7%. Additionally, DME eyes exhibited poor functional and anatomical outcomes after developing ERM, while age, A1c level, DR severity, initial BCVA and CMT, lens status, and previous laser treatment were not associated with an elevated incidence of ERM formation. Intravitreal DEX implantation in DME eyes resulted in a higher incidence of secondary ERM formation compared to aflibercept over a 2-year period. The therapeutic efficacy for DME was diminished following ERM development, leading to worse anatomical outcomes. New therapeutic approaches should be explored to prevent ERM formation while maintaining both anatomical and functional outcomes in DME treatment.