Why do non-metals gain electrons?

they gain electrons because they need an electron to fill there outer most shell to make it stable !!!

Nonmetals have high electronegativity (Ability to attract electrons) so they attract more electrons then lower electronegativity elements.