Mg++ is an ion with a charge of +2. Calcium ions also have a charge of +2 and thus the 2 ions antagonize each other. Potassium ions have a charge of +1 and also antagonizes Mg and Ca since it has a positive charge. Too much Ca++ will lock out K+ and Mg++ and you will likely notice signs of Mg deficiency when there's plenty of Mg.
Negatively charged ions like NO3- and H2PO4- also antagonize each other. Too much H2PO4- will lock out NO3- and leaves will start to yellow. Everyone knows that one.
This is why ratios like N : P2O5 : K2O and K:Ca:Mg are important.
Just a note, I wouldn't call Mg a trace element. It's once of the 6 elements needed in abundant quantities, N, K, Ca, P, Mg, S. Trace elements include iron, boron, manganese.
Lockout due to pH is a bit different. When pH is high, H2PO4- becomes HPO4--. Plants specifically look for the H2PO4- form of P. To make things worse, HPO4-- form has a tendency to join with Ca++ to make CaHPO4, a very insoluble salt, leaving your reservoir unstable.
looking to advance in nutes, so trying to understand trace elements and what they do.