In: Biology
Well, first you should know that atom of stable molecule can make both type of covalent and ionic bond.
Now, let's see why some form covalent bond instead of ionic bond.
You know that in ionic bond complete transfer of electron occur and electronegativity difference between two atoms is quite high , so one losses electron and one gains that electron.
But in covalent bond instead of transfer of electron , sharing of electron occur because the difference of electronegativity is quite low. So, between these two no one wants to gain or loose electron.
For example NaCl , Here Na have low Electronegativity and Cl have high Electronegativity. So, Na looses electron and Cl gains electron. So, they form ionic bond.
Now consider Cl2 , here both atoms are same , so the Electronegativity difference between these atoms is quite low or you can say equal to zero. So, they form covalent bond by sharing their electron.
( This is all a game of Electronegativity difference.)
In case of any doubt , ask me.