Question: What are the factors that help the Earth to form a magnetic field around itself and why it is spread throughout from South to North?

Answer: 
The outer core of the Earth is a fluid consisting of molten iron, nickel, cobalt and other ferromagnetic metals. These are in constant motion. Their motion and the high temperature together cause the production of the Earth's magnetic field. Since the source of the field is itself dynamic, the magnetic field of the earth is also dynamic, and changes constantly changes on a cosmological timescale (1000s of years). This is the basic idea of the hydrodynamic dynamo model, as referenced in the comment below your question.
The Earth's outer core is essentially made of molten iron, nickel, cobalt and other ferromagnetic metals, which are in constant motion. With these elements inside the outer core and in motion, they help create Earth's magnetic field. This is the basic idea of the hydromagnetic dynamo model:

> 
> Convection currents of magma in the Earth's outer core, driven by heat flow from the inner core, organized into rolls by the Coriolis force, creates circulating electric currents, which generate the magnetic field.
> 
> 
> 

Source for quote: <https://en.wikipedia.org/wiki/Dynamo_theory>