Ions are formed when atoms of element gain or loose electrons.
When an atom looses electrons it forms a positively charged ion and when an atom gains electrons it forms a negatively charged ion.
Metal atoms such as potassium, magnesium and aluminium looses outer most electrons to positively charged ions.
Potassium atom has 19 electrons, 19 protons, with an electronic configuration of 2 : 8 : 8 : 1.To form an ion, K looses an electron to form a positively charged potassium ion (K+) with 18 electrons and 19 protons and an electronic configuration of 2:8:8.