Magnetic lines form continuous closed loops because magnetic monopole does not exist in nature. We always find magnetic poles - North and South pole which are coupled together in such a way that field lines originating from one pole ends at the another loop, forming a closed loop.