The number of protons in an atom is determined by its atomic number, which is unique for each element. For example, hydrogen has an atomic number of 1, meaning that it has one proton in its nucleus. Carbon has an atomic number of 6, meaning that it has six protons in its nucleus.
The number of electrons in an atom is equal to the number of protons, so hydrogen has one electron and carbon has six electrons. These electrons are arranged in shells around the nucleus, with the innermost shell being closest to the nucleus.
The outermost shell of electrons is called the valence shell, and the number of electrons in the valence shell determines an atom's chemical properties. Atoms with a full valence shell are stable and do not react easily, while atoms with an incomplete valence shell are reactive and tend to form chemical bonds with other atoms in order to complete their valence shell.