The atomic/ionic size of Na and K is larger than that of Mg and Ca.
Hydroxides and carbonates of Na and K have lower lattice enthalpies than those of Ca and Mg. This results in high solubility for hydroxides and carbonates of Na and K whereas those of Mg and Ca are sparingly soluble.