First-principles study of electronic and dynamic properties of AgMg and AgZn