In the periodic table this is known as a 'diagonal relationship'. The diagonal relationship is because of similarities in ionic sizes and charge/radius ratio of the element. The similarity between lithium and magnesium is because of their similar sizes: