How do ions form electrically neutral compounds?
By balancing the charge on the individual ions.
Salts are electrically neutral (of course all matter is electrically neutral). If the species contains an anion, there must be cations to balance the charge. It is easy to apportion charges in salts of the halides and the alkali metals, i.e
Lithium nitride is known. If you know that the nitride anion is