Molecular dynamics simulations were used to investigate the influence of pressure on the structural properties and dynamics of magnesium (Mg) during rapid solidification. The dynamics analysis revealed that, with an increase in pressure, the dynamics of Mg melt slowed down sharply and the dynamical heterogeneities increased, leading to a denser structure. Atom-level structural analysis using the cluster-type index method suggested that the predominant structure transformed from hexagonal closed-packed to face-centered cubic with increasing pressure from 0 GPa to 5 GPa, and then transformed to the A15 complex crystal structure as the pressure increased above 10 GPa. In addition, the nature of polymorph selection was investigated by analyzing the phonon dispersion of Mg under different pressures. These findings provide a novel insight into polymorphic transitions of Mg under pressure and guide the selection of Mg polymorphs for practical applications.