Honeycomb or triangular lattices were extensively studied and thought to be proper platforms for realizing quantum anomalous Hall effect (QAHE), where magnetism is usually caused by d orbitals of transition metals. Here we propose that square lattice can host three magnetic topological states, including the fully spin polarized nodal loop semimetal, QAHE and topologically trivial ferromagnetic semiconductor, in terms of the symmetry and k$cdot$p model analyses that are materials-independent. A phase diagram is presented. We further show that the above three magnetic topological states can be indeed implemented in two-dimensional (2D) materials ScLiCl5, LiScZ5 (Z=Cl, Br), and ScLiBr5, respectively. The ferromagnetism in these 2D materials is microscopically revealed from p electrons of halogen atoms. This present study opens a door to explore the exotic topological states as well as quantum magnetism from p-orbital electrons by means of the materials-independent approach.