First-principles prediction of electrochemical polarization and mechanical behavior in Mg based intermetallics