How do we know which atoms form anions, and which atoms form cations?
IF the atom is a metal, probably its ion will be a cation. If the atom is a non-metal, probably its ion will be an anion.
Metals are generally electron rich species from the left hand side of the Periodic Table as we face it. Their nuclear charge tends to be shielded and they readily lose electrons forming cations.
On the other hand, non-metals come from the right of the Periodic Table. Their nuclear charge tends to be inefficiently shielded by the incomplete electronic shells, and these tend to gain electrons forming anions.