Background: Cognitive impairment and dementia may result from a combination of modifiable and nonmodifiable risk and protective factors, such as the environment, educational attainment, time devoted to cognitively stimulating activities, and physical activity. Objective: This study aimed to investigate the mediating role of sociodemographic characteristics and lifestyle factors in the years of education and cognitive performance in Peruvian adults. Methods: This cross-sectional study included 1,478 subjects assessed by Addenbrooke’s Cognitive Examination Revised (ACE-R). Using mediation models, we evaluated the mediation role of parents’ educational level, reading time (RT), and physical activity time (PAT) in the years of education (IYE) and cognitive performance. Results: People who reported having lived in an urban area during their childhood are estimated to have, on average, 2.085 years more formal education than those who lived in rural areas. In addition, 49% of cognitive performance scores are explained by the mediation effect of reading and physical activity time in the IYE. This implies that higher levels of education, mediated by RT and PAT per week, are 1.596 units associated with higher scores on the ACE-R. Conclusion: Despite the fact that nonmodifiable factors (i.e., childhood residence area, parents’ educational level) seem to exert an effect on older adults’ cognition, their influence is mediated by other factors that are indeed modifiable (i.e., reading time, physical activity engagement). In this sense, lifestyle changes could help prevent or decrease the risk of cognitive impairment and reduce the disease’s impact on vulnerable environments in Latin American and Caribbean countries.