https://abn.churchofjesuschrist.org/study/manual/gospel-topics/baptisms-for-the-dead?lang=eng
Jesus Christ taught that baptism is essential to the salvation of all who have lived on earth (see John 3:5). Many people, however, have died without being baptized. Others were baptized without proper authority. Because God is merciful, He has prepared a way for all people to receive the blessings of baptism. By performing proxy baptisms in behalf of those who have died, Church members offer these blessings to deceased ancestors. Individuals can then choose to accept or reject what has been done in their behalf.
At the same time, Mormon teaches in Moroni 8 that children who die before the age of accountability, don't need baptism, because they don't need repentance. And as far as I understand, being under a commandment requires knowledge of that commandment.
It's clear that, in order to be saved, even the dead have to accept Christ. But why do they need to subject themselves to a ritual that they can't themselves complete anymore?
In the phrase Jesus Christ taught that baptism is essential to the salvation of all who have lived on earth
, what exactly is the meaning of "essential" and "salvation"?