Well, you can find some kind of explanation why the electronic configuration of $\ce{Co^2+}$ is $[\ce{Ar}] \, 3d^7$ here and there, but at the end of the day, you just need to * memorize it*.
When d-block elements form ions, the $4s$ electrons are lost first. Source
The $n+l$ rule tells you the order in which atomic orbitals are filled, and according to the rule the $4s$ orbital is occupied before the $3d$ orbital because it has lower energy.
Thus, the electron configuration of $\ce{Mn}$ is $[\ce{Ar}] \, 3d^5 4s^2$ while that of $\ce{Co}$ is $[\ce{Ar}] \, 3d^7 4s^2$.
But, the $n+l$ rule, as many other rules of old quantum theory, is not 100% working, and thus, sometimes gives wrong electron configuration.
For instance, in general, it is applicable only for neutral atoms in their ground state, and thus, if you apply it to cation $\ce{Co}^{2+}$ you will get the wrong electron configuration [\ce{Ar}] $3d^5 4s^2$.
As it is sometimes explained, the statement that $4s$ orbital is lower in energy than $3d$ orbital is true only when the orbitals are unoccupied. But while you fill $3d$ orbital with electrons it becomes lower and lower in energy and eventually ends up lower in energy than the $4s$ orbital. Thus, when electrons are lost from $\ce{Co}$ atom, they are lost from the 4$s$ orbital first because it is actually higher in energy when both $3d$ and $4s$ are filled with electrons.
P.S. And if I remember correctly this has nothing to do with stabilization in ligand fields.