Why Siva replaced Ganesha head with Elephant

Hidden meaning of Parvati creating her son with scurf and grime and Ganesha human head replaced by Siva with elephant head in Puranas
Puranam Pancha Lakshanam – A text should have 5 characteristics or Pancha-Lakshana to be classified as a Purana. They are
Sargascha pratisargascha
Vamso Manvantarani cha
vamsaanucharitam chiva
puranam panchalakshanam

The text should be talking about
Sarga: Some scholars say this should be the proper breakdown into chapters, while some others are of the opinion that sarga means creation. So the Purana should have proper distinction about chapters and it should speak about the creation of the universe.
Pratisarga: again some say this relates to sub-chapters. Others opine that it should be about secondary creations, mostly re-creations after dissolution.
Vamsa: It should speak about the great Vamsas or the Genealogy of the great Rishis and the Devatas.
Manvataranicha: It should speak about the Manavantaras or reigns of Manus. Each Manu rules over an eon, each of which is shorter than the preceding ones. Currently, we are in the vyavastha manvantaram.
Vamasanucharitam: It should give a detailed description of the dynasties of Kings who lived and ruled this world – mostly, the great SuryaVamsh and the Chandra Vamsh or the Solar and Lunar Dynasties.
Out of these, except for history part which includes family lineage of kings, most of the puranic stories are allegories.
Cosmic forces like Siva, Vishnu, Lakshmi, Parvati, Ganesha, Kartikeya etc and their properties are told as human stories to simplify the complicated stories of evolution.

Earliest mention of Ganapati is found in Rig Veda, hymn 2.23.1.
Siva Purana, Rudra Samhita – Kumara Khanda, chapter-13 describes birth of Ganesha.
In multiple kalpas, Ganesa evolved differently. That is the reason behind multiple stories of his birth.
In present Sweta Varaha Kalpa, his head was cut off by Siva.
Parvati created a person from her body scurf and grime to obey her orders and be her gatekeeper. Parvati says “You are my son. You are my own. I have none else to call my own. Without my permission, no one, by any means, shall intrude.
Ganesha Human Head
When Parvati went to take bath, Siva came and was blocked at entrance by this kid.
During the battle, Ganesa hit all gods including Vishnu, with his shaft.
Vishnu said : “I shall cause him delusion (maaya). Then let him be killed by you, O lord. Without deception he cannot be killed. He is of Tāmasika nature and inaccessible.
During this battle with Vishnu, Siva came there and cut off his head with his trident (Trisool).

Seeing this, parvati ordered Saktis to destroy all gods present over there. Karālīs (the Terrific), Kubjakās (the humpbacked), Khañjās (the lame), Lambaśīrṣās (the tall-headed) the innumerable Śaktis took up the gods with their hands and threw them in their own mouths.
It appeared as if parvati would create an untimely dissolution (Pralaya).
To please her, Siva sent his men to cut off any living being sleeping with head towards north direction.
They bring elephant head and Siva attaches it to Ganesa’s body.
Siva Ganesha Parvati

Shiva Shakthi Kundalini Yoga
Siva Sakti energies created Kundalini together, but Siva replaced human level energy with elephant level energy to help awakening of Kundalini.

Mooladhara Kundalini Sakti LingamThe fact that one should not sleep with his/her head placed towards north (body aligned in straight line with north and south pole of earth) is told in allegoric manner here.
Also, Siva wanted a head which is in alignment with one of the four elements, Earth (North). Parvati, the female energy or Yin, tried to create Mooladhara Chakra with human energy (told as human head symboliically) to hold Kundalini energy.
In the center of the mooladhara square, below the seed syllable, is a deep red inverted triangle. The kundalini sakti is said to sleep here, waiting to be aroused and brought back up to Brahman, the source from which it originated. It is represented by a snake wrapped three and a half times around a smoky grey lingam.
Goddesses Bhairavi and Kubjika are associated with Kundalini energy, which was told in a story above.
This Kundalini, when cultivated and awakened through tantric practice, leads to spiritual liberation (moksha or niravana).
For this to happen, kundalini (serpent energy), which is upside down, needs to be flipped vertically and then sent upwards through the spine.
All this happens in split second and kundalini reaches sahasrara chakra (crown) within no time. But for that, all chakras need to be activated and aligned with spine.
Ganesha in Mooladhara Chakra with Dieties

The way Om is written in Sanskrit (ॐ) shows the three-and-half matras of Kundalini Sakti potentially present in the breath of every human being. Om means the eternal, pure Self. Om is the first cosmic sound, the ruler of all basic elements and creation. It looks like the head of a happy elephant with a raised trunk trumpeting joyfully and is represented by the Sanskrit script ॐ.
This is Lord Ganapati, the son of Siva and Shakti. As a son is the pure quintessence of the parents, so is Lord Ganapati, who is represented by the Sanskrit letter ॐ.
This is why Ganapati has the head of an elephant and the body of an innocent, young baby. The body of the baby symbolises the microcosm or man and the head of the elephant, the macrocosm or the universe. Thus, there is a union of the universe and man in the embodiment of Lord Ganapati. He is the monarch of Kundalini and that is why he wears a cobra as a belt around his waist. Kundalini remains dormant in most people but becomes awakened with spiritual development.

Ganesha as Elephant energy in Mooladhara Chakra

7 Chakras formation in FoetusKundalini creates a strong desire to make love, ejaculate sperm and serves the meeting of the male seed and female egg. Thus, the conception, implantation and growth of a foetus is regulated by Kundalini.
During pregnancy, Kundalini remains in the crown chakra of the foetus and keeps the baby in the passive state of a blissful life.
There is no consciousness of the physical body at that time. But, during the hour of delivery, Kundalini assists the baby to come out of the womb.
Gradually the baby comes out, air touches the baby’s skin, Kundalini stimulates respiration, and the baby breathes.
As this is happening, Kundalini moves down to the sacral plexus (sahasraha chakra) and brings physical consciousness to the child.
Baby forgets its blissful state and starts crying. At this moment, the parents become happy but the child looks unhappy, because it has lost state of bliss.
Crying baby lies on the three-fold lap (the three matras) of the Mother Kundalini.
Without her blessings, no one attains the spiritual state of bliss.
In the true sense, Kundalini is the Divine Mother of all creatures.
All our happiness, unhappiness, health, ill-health, creativity, passivity and total span of life is managed by Kundalini.
Ganapati, who evokes kundalini is thus regarded as Vighna-Nasaka or Vinayaka (obstacle destroyer), to attain brahman.

Siva replaced human head with elephant head because, kundalini requires strength of an elephant to get activated. Original human level energy cannot awaken it.
But, the original ganapati, also known as Aadi Vinayaka is still worshipped with human head in a temple near Koothanur, Tamil Nadu.
Ganesha with human head as Aadi Vinayaka
This is probably from one of previous kalpas, where Vinayaka has grown into an adult and his head not yet replaced.

Moola+Adhara means the root cause or basis of of our existence.
It is seat of the KARMAS from earlier lives and our destiny in present life.
Only when elephant energy is used to activate kundalini in it, our karmas start to get destroyed and we attain salvation.
A person with displaced or imbalanced mooladhara chakra, will not be grounded, will be detached to or not have proper relation with mother, father, family, environment, home, workplace, boss, job, career, money.
Only an elephant headed Ganesa at Mooladhara chakra can help us attain that balance and upliftment.

Karma in Mooladhara Chakra
Our obstacles (Vighna) in this life are due to effects of past karmas, which can be nullified by evoking Ganesha at Mooladhara. That is why this energy is called Vighnadhipati or Vighna-Nayaka or Vinayaka.
Siva’s ganas are his forces surrounding him, which act upon his command.
When Siva replaced human head of parvati’s son with that of an elephant (Gaja), the kid was called Ganapati or Ganesha, or Gajapathi or Gajesha.
Head of one of the ganas (Gajasura) was used as replacement and the kid was made leader of Ganas (Ganesa or Ganapathi).
Gana is actually multitude in sanskrit and Ganesa is leader of them.

Ganapati Atharvashirsa, an upanishad attached to Atharva Veda, asserts that Ganesha is same as the ultimate reality, Brahman.
It is also called as the Ganapati Upanishad.
त्वं मूलाधारस्थितो॑‌सि नित्यम् , which means that You continually dwell in the mūlādhāra chakra.
Bija mantra, gam is used in Ganesha Purana.

Ganesa lives in turiya sthiti (4th state), which is Bliss, while earlier 3 states being Jagrat (awake/conscious), swapna (dream), sushupti (deep sleep), which are common for all living beings.
Ganesha in Turiya Sthiti (Bliss)