2. A non-metallic atom gains electrons and gets converted into a negatively charged ion(anion).
3. These cations and anions have opposite charge and experience a strong attraction for each other, so they remain tightly held together forming ionic or electrovalent bond.
Hence ionic compounds are formed due to the combination of metals and non-metals.