The formation of cation is an endothermic reaction because to form cation, you need to supply heat. This is because a cation means losing electrons to gain the charge. Losing electrons means removing the electrons from respective atom. The heat supply would eject the electron from the atom. Hence, supplying heat means endothermic reaction.
On the other hand, formation of anion is an exothermic reaction. The following reaction is exothermic because the heat is released when we add electrons in the atom.