What is the main way that atoms gain or lose either atoms or electrons?
This question cannot be satisfactorily answered as given: an atom cannot simply lose or gain an atom, in the same way that a bucket cannot lose or gain a bucket. The atom is the essential unit of "identity" when it comes to matter. If you start with an atom and "lose" that atom, you have nothing. If you add an atom, you now have a molecule or compound.
The only way in which a single atom could literally lose or gain an atom is through atomic fission or fusion, but this requires more careful wording than provided. Fusion involves two or more atoms binding together to make a larger atom, and fission involves an atom splitting into smaller atoms. Both processes require that the total matter remains constant throughout the reaction; therefore it would be impossible for hydrogen to undergo fission, thereby rejecting the way this question is phrased. In reality, it is usually small atoms that undergo fusion, such as in stars, and large atoms that undergo fission, as in nuclear weapons or reactors.
As far as compounds and molecules go, the means by which molecules typically gain or lose their atomic components is through chemical reactions that transfer energy either in or out of the molecule. Two single atoms are often highly energetic and reactive; therefore a molecular binding will "add" these atoms to each other, while reducing the total energy of the compound. Likewise, adding energy to this compound, such as by heating it, will eventually break the bond and cause the compound to "lose" these atoms.
By definition an electron is a negatively charged component of an atom. The atom itself is an entity made up of smaller entities, so it is odd to speak of atoms losing atoms.
With regards to gaining or losing electrons, this occurs through a process referred to as bonding, more specifically, ionic or electro-valent bonding. During this process, an atom can lose one or more electrons from another atom, thereby forming positive ions (cations) or gain one or more electrons to become negative ions (anions).
As shown in the diagram above, the magnesium atom loses 2 electrons to an oxygen atom. The magnesium atoms becomes a cation because it now has 2 more positive charges (protons) than negative charges (electrons). It can be represented as Mg2+.
On the other hand, the oxygen atom, having received the two electrons from magnesium becomes an anion, because it now has 2 more negative charges (electrons) than positive charges (protons). It can be represented as O2-.
The movement of the electrons is a function of the atoms atomic number (number of protons in the nucleus), and how far the valence electrons (those in the outermost orbit) are from the pull of the nucleus.
Atoms cannot lose atoms, however larger atoms (meaning, heavy elements) can break down into smaller atoms (lighter elements) by nuclear fission. An example is uranium (U-235) atom which breaks down into Krypton (Kr-89) and Barium (Ba-141). So in a way Uranium lost atoms. Similarly, nuclear fusion causes conversion of lower molecular weight elements into heavier elements. But an atom cannot lose itself.
As for losing electrons is concerned, atoms can lose electron during bonding process. In ionic bonding, an atom transfer electron to another atom. An example is the bonding of sodium and chlorine to form sodium chloride. Sodium loses an electron to chloride and forms ionic bond and this results in formation of sodium chloride. Several other examples of ionic bonding (electron lose by cations) can be found in literature.
Hope this helps.
Atoms lose electrons by a process called ionic bonding. Specifically, the metal atom donates its electron to a non-metal atom and thus takes on the noble gas electron configuration of the noble gas in the period (row of the periodic table) preceding its own. In this way the metal atom forms what is called a cation which is just a positively charged ion.
The process is called ionization and the energy involved in the process - providing that the atom and the ion are gaseous - is called the ionization energy.