To study the formability of AZ31 magnesium alloy under different temperature conditions and improve the forming quality of its parts, this paper aims to solve the minimization problem of pursuing the “maximum thinning rate”. This study obtained the mechanical properties of AZ31 magnesium alloy at 25 °C, 150 °C, 250 °C, and 350 °C through uniaxial tensile tests and explored the stamping formability of AZ31 magnesium alloy mobile phone cases using the finite element inverse calculation method (MSTEP). Based on the hot stamping of AZ31 magnesium alloy at 250 °C, the Monte Carlo Simulation (MCS) method was used to randomly sample the blank holder force, stamping speed, friction coefficient, and resistance coefficient, and then simulate to obtain the corresponding “maximum thinning rate”. In addition, a hybrid prediction model optimized by Genetic Algorithm (GA) and Dung Beetle Optimization (DBO) based on the Back Propagation Neural Network (BPNN) - Random Forest (RF) was used to explore the nonlinear relationship between blank holder force, stamping speed, friction coefficient, resistance coefficient, and the “maximum thinning rate”. The results show that the plasticity of AZ31 magnesium alloy enhances with the temperature increase, especially exhibiting the best stamping formability at 250 °C. Feature importance indicates that the resistance coefficient and stamping speed have a greater impact on the maximum thinning rate, while the influence of blank holder force and friction coefficient is relatively smaller. Mean Square Error (MSE) shows that the predictive capability of the hybrid model is significantly superior to that of the single BP neural network and Random Forest model, displaying optimal efficiency. The predicted maximum thinning rate by the model is 15.39 %, with an error rate of only 0.32 % compared to the DYNAFORM finite element software simulation results, confirming the correctness, accuracy, and effectiveness of the prediction model. Overall, this study provides practical optimization strategies for metal stamping forming processes, with significant practical application value.