the reason is you are not considering the total mass of the nucleus which contains a number of neutrons (as well as the binding energy of the nucleus). While Nickel may have 28 Protons in its nucleus, compared with Cobalt which has 27, Nickel has 31 Neutrons, compared with 32 neutrons in Cobalt. So while they may both have the same number of nucleons (N) in their nucleus (N=59), they have different proportions of protons and neutrons.
The big factor here is that neutrons have a slightly larger mass than the proton. In atomic units, the mass of a proton is 1.00728 u compared to the mass of a neutron of 1.008665 u. So if you do the summations you find that Cobalt will have a total nucleon mass of (27x1.00728 + 32x1.008665 = 59.47384) compared to Nickel which has (28x1.00728+31x1.008665 = 58.465175). So as you can see because of the difference in masses between the proton and neutron, Nickel has a lower mass than Cobalt, even though it is higher in atomic number on the periodic table. We can effectively neglect the mass of the electrons of the atoms, since they are about 1/1836 the mass of a proton (or 0.0005486 u), and contribute little to the overall mass of an atom.
Now, you will have noticed that the above calculation does not reproduce the measured masses. That is the above calculation gives total masses larger than the measured masses. The reason for this is that the above calculation does not factor in binding energy within the nucleus. In order for the nucleons to bind in a stable configuration, it must minimise its energy, i.e. it must get rid of some energy. You can think of it like this, in order to split the individual, you must provide more energy than their binding energy that sticks them together. Hence you put energy to the system to break it apart. So if we reverse this principle, energy must be given out in order to bind the nucleus together, and hence the energy of the nucleus is said to be minimised.
Where does this energy come from? Well it comes from the mass of the nucleons, via E=mc^2. A little bit of mass from the nucleons is given up in the form of energy to bind the nucleons into a stable configuration.
This is then the principle of nuclear energy for power and weapons. In both fusion (as in the sun, or fission in nuclear weapons or reactors, you are altering the number of nucleons within a nucleus to release energy. In fusion for example, you fuse deuterium (1 proton and one neutron) to form Helium (two protons and two neutrons). The binding energy of helium is much less than the total binding energy of the two deuterium nuclei, and so when the nuclei fuse, one gets an excess of energy (usually in the form of heat) released through the difference in binding energies of the mother and daughter products.
Fission is similar, but you are splitting a heavier nucleus into two lighter nucleus, whose total binding energies are less than the binding energy of the original nucleus. hence you get a net release of energy from the reaction.
Note, that in the above I am defining the Binding energy as negative as measured from a zero level. Thus two nucleons that are not bound will have a binding energy greater than or equal to zero, and that when bound the binding energy will be less than zero. In this convention the negative sign denotes energy subtracted from the system, and positive sign is energy added to the system. Ultimately it doesn't matter what level you define your energies with respect to as energy is a scalar quantity, just as long as you keep the maths self consistent.
This post was created using 100% recycled electrons