In this paper we prove the Hardy inequalities for the quadratic form of the Laplacian with the Landau Hamiltonian type magnetic field. Moreover, we obtain a Poincaré type inequality and inequalities with more general families of weights. Furthermore, we establish weighted Hardy inequalities for the quadratic form of the magnetic Baouendi-Grushin operator for the magnetic field of Aharonov-Bohm type. For these, we show refinements of the known Hardy inequalities for the Baouendi-Grushin operator involving radial derivatives in some of the variables. The corresponding uncertainty type principles are also obtained.