Strong Nuclear Force
Iron atom diagram
But the strong nuclear force pulls the protons together. As you might think from the name, the strong nuclear force is very strong. It is stronger than electricity or gravity. But the strong nuclear force only works when it is very close to something.
In fact, the strong nuclear force only works when it is as close to a proton as the diameter of a proton or a neutron (or closer). When one proton or neutron gets this close to another proton or neutron, tiny particles called mesons begin to bounce back and forth between the two protons, and this holds the two protons (or neutrons) together.
But it's hard for two protons to get that close together, because their positive charges tend to push them away from each other. Protons can only get close enough to each other to form atoms (other than hydrogen) by moving very quickly so that their momentum will carry them close together. When protons move very quickly, that's the same thing as heat, so protons have to be very hot in order to stick together and make atoms. That's why atoms form inside stars, where it is very hot.
It also helps the protons stick together if there are some neutrons around. The neutrons don't have any electrical charge, so they just keep the protons separated enough so they don't push away from each other so much.