Why does table salt lock itself into a giant 3D pattern?
Your salt shaker is full of particles that are not paired up as tiny NaCl molecules. In solid sodium chloride, your particles build a huge repeating structure instead. That happens because once atoms turn into charged particles, attraction works in every direction around them.
Ionic bonding happens when one atom gives away electron(s) and another atom takes them, creating oppositely charged ions that stay together because of electrical attraction.
You usually get this kind of bonding when a metal reacts with a non-metal. A metal atom can lose outer electron(s) more easily, while a non-metal can gain them. It is a bit like one person sending game coins to another account: one side ends up short, the other ends up extra full, and that imbalance creates a strong pull between them.
Ion means an atom, or group of atoms, that is no longer neutral because the number of electrons and protons is unequal.
Cation is the name for an ion with a positive charge, formed when electrons are lost.
Anion is the name for an ion with a negative charge, formed when electrons are gained.
Electrostatic forces are the pushes and pulls between charged particles.
If your ions have matching charges, they push apart. If their charges are opposite, they pull together. That one idea explains why ionic substances form the structures they do.
The surprising part is this: a single electron moving from one atom to another can completely change the kind of structure you get. You do not end up with a few atoms loosely attached. You get a rigid giant arrangement with strong attractions spread through the whole solid.

6 more sections in this topic
Pick this up in your Library: it holds the whole topic, notes, cheatsheet and questions.