actuali gaining n losing is mainly for metal with non-metal
compounds, tt is when they form ionic products...
when its non-metal n non-metal is form covalent compound, tt is
when they share electrons...
eg. hydrogen has 1 electron, share with another hydrogen, so both
of them haf 2 electrons, thus stable(1st principle quantum shell
can hold 2 electrons).
oxygen has 6 electrons on its outermost shell, thus it needs 2 more
to haf a stable octet structure, therefore it shares 2 electron
with another oxygen atom, O::O, therefore 4 in the middle + 4
remaining ones arnd it to form 8 electrons...
or if u wan easy way out, most gaseous elements exist as diatomic
molecules...