Why do plants need potassium and magnesium ?
Potassium and magnesium both are essential elements as

Potassium -  is involved in maintaining the turgidity of cells and in the activation of enzymes. It helps in the opening and closing of stomata, to determine anion-cation balance in the cells, formation of cell membrane and in translocation of organic solutes in the phloem.

Magnesium-  is a constituent of chlorophyll. It is required in fat synthesis and nucleic acid synthesis. It activates enzyme in phosphate metabolism.