Valence state determines the band magnetocrystalline anisotropy in 2D rare-earth/noble-metal compounds