Why Earth behave like a magnet? Explain magnetic elements of earth at a place giving expressions.
The Earth behaves like a magnet because the Earth is a magnet. It is not a permanent magnet, but an electromagnet.
We now understand why. Deep in the Earth, molten metal (mostly iron) flows due to heat which causes convection. (The heat appears to be generated by iron condensing at the solid core.) This flow tends to organize itself into patterns, just like the patterns you’ll see in oil if you heat it in a frying pan. Such patterns in a flowing conductor tend to create magnetism. The same idea is used in the “dynamo”, a device that creates both electric current and magnetism from moving conductors. Commercial dynamos are the source of essentially all of our wall-outlet electricity.
The principle of a dynamo is this: if there is a little magnetic field, then when a conductor moves past it, it causes current to flow. That current creates a magnetic field which, if the geometry is right, enhances the original field. So it grows until the force is large enough to modify the pattern.
The question of why the magnet sometimes flips is not yet settled. I wrote a scientific paper on this, and I hope (actually, to be more candid, I expect) that my theory will some day be proven correct. It says that the flow pattern is disrupted by an instability in the material that is deposited by the flowing iron at the core-mantle interface. This leads to a disruption of the dipole character of the field, which is then restored as the pattern reestablishes itself; however, it has a 50% chance of coming back in the opposite direction.