Researchers have focused extensively on understanding the factors influencing students' academic achievement over time. However, existing longitudinal studies have often examined only a limited number of predictors at one time, leaving gaps in our knowledge about how these predictors collectively contribute to achievement beyond prior performance and how their impact evolves during students' development. To address this, we employed machine learning to analyze longitudinal survey data from 3,425 German secondary school students spanning Years 5 to 9. Our objectives were twofold: to model and compare the predictive capabilities of 105 predictors on math achievement and to track changes in their importance over time. We first predicted standardized math achievement scores in Years 6 to 9 using the variables assessed in the previous year ("next year prediction"). Second, we examined the utility of the variables assessed in Year 5 at predicting future math achievement at varying time lags (1-4 years ahead) --- "varying lag prediction". In the next year prediction analysis, prior math achievement was the strongest predictor, gaining importance over time. In the varying lag prediction analysis, the predictive power of Year 5 math achievement waned with longer time lags. In both analyses, additional predictors, including IQ, grades, motivation and emotion, cognitive strategies, classroom/home environments, and demographics (including SES), exhibited relatively smaller yet consistent contributions, underscoring their distinct roles in predicting math achievement over time. These findings have implications for both future research and educational practices, which are discussed in detail.