This is because nonmetals have a higher electronegativity, meaning they have a stronger attraction for electrons. By gaining electrons, nonmetals can achieve a stable electron configuration similar to that of a noble gas, which is more energetically favorable. This process allows nonmetals to form negatively charged ions, known as anions, which have a full outer electron shell.