Non-metals react by :
accepting or sharing electron.
Any element reacts to obtain stability which is obtained when the element gains noble gas configuration. As non-metals have more than 3 electrons in their valence shells, hence for them it is easier to accept electrons to obtain noble gas configuration or share electrons to form covalent bonds as in case of carbon. Hence non-metals react by accepting electron and forming covalent bonds.