Are cations created because the element is a metal and anions created because it is a non metal? Or is it the number of electrons and protons in the nucleus that determines the charge of an ion? Or maybe both?
The reason why cations are created from elements that are metals and anions created from elements that are non metals is due to the electronic configuration of elements that are metals and non-metals.
Metals are usually elements that have one, two or three electrons in the outermost shell that the atom can lose to form cations which are more stable than the atom of the metal. The loss of the electrons results in the electronic configuration of a noble gas.
Non metals on the other hand have an electronic configuration where the number of electrons is less than the number of electrons in the nearest noble gas by a few electrons. This makes it easy to attain the noble gas configuration by acquiring the required number of electrons and getting converted to an anion.
The required reason for what has been asked is that the electronic configuration of metals is suited for the creation of cations and that of non metals is suited for the creation of anions.