Abstract Understanding mechanical properties of silicon oxynitride (a-SiON), a key insulating material, is vital for electronic device design and reliability. Though the effects of fabrication conditions on a-SiON have been studied, the underlying relationship between its atomic-scale structure and mechanical properties remains unclear. This study investigates the relationship between elasticity and atomic-scale structures in a-SiON by molecular dynamics simulations with a universal graph neural network interatomic potential. The bulk modulus increases from 49 to 140 GPa with higher N content. N atoms form N2 molecules under O-rich conditions, hindering bulk modulus increase, and form an Si3N4-like network under O-poor conditions, enhancing bulk modulus. Formation energy calculations indicate N2 formation is preferable under O-rich conditions. Meanwhile, under O-poor conditions, Si-N bond formation is preferable, which reinforces a-SiON by increasing bond density. The findings suggest realizing O-poor conditions is crucial for highly elastic insulating films.