Non-metals are electronegative in nature. They have very high electron affinity to complete their octet where as metals are electropositive in nature they lose electrons to attain noble gas configuration.
So their takes place a complete sharing of electrons between the metal
and non-metal forming bond between them. Such bonds are called ionic
bonds. In this way metal and non-metal react.