Microscopic Link between Electron Localization and Chemical Expansion in AMnO3 and ATiO3 Perovskites (A = Ca, Sr, Ba)