Atoms are stable so how can they pull electrons i.e how do they have any electron affinity at all?
2 Answers
Actually, not all atoms are stable, at least not in the gas phase, which is where we measure the electron affinity. You should first read Why do atoms "want" to have a full outer shell? for detailed elaboration.
Now, electron affinity involves the gain of an electron to an isolated gaseous atom, but not all atoms actually want to gain an electron, i.e., they are already pretty stable. This is precisely the reason why elements like the noble gases or nitrogen have negative electron affinity i.e. you need to supply energy for them to accept an electron.
Also read: Are there any major exceptions when comparing electron affinity?
So, in short: "Atoms are stable so..." not always, in fact, such atoms are in the minority. "...how can they pull electrons..." read the first link. "how do they have any electron affinity at all?" we can always supply excess energy to make an atom accept an electron, forcibly. So, the only difference for stable vs non-stable atoms would be the sign of electron affinity.
The energy necessary to detach an electron from an atom is called the ionisation energy. It has a large positive value for atoms with filled shells, such as the noble gasses, and is much smaller with atoms with one more electron, such as alkali metals in which the electron is easily released. The value is positive with the convention that energy is absorbed.
The electron affinity is the energy released when an electron is added to an atom $\ce{X(g) + e^- \to X^-(g)}$ and this energy released is, confusingly, by convention also a positive value. Thus for fluorine the electron affinity $\ce{F(g) + e^- \to F^-(g)} = 333$ kJ/mol) so this much energy is released, but is $-31$ for N atoms in which adding an electron is unfavourable (energy absorbing).
Thus the 'stability' of atoms as you call it is reflected in the energy released when an atom gains an electron ( or absorbed when an electron is removed and the ionisation energy is measured) and these reflect the energy of the different levels filled by the specific number of electrons that each type of atom contains.