A comparative study of the magnetic and electrical properties of perovskite oxides and the corresponding two-dimensional oxides of K2NiF4 structure