LDS temples are designed so that ordinances can be performed not only for the living, but for the dead. Mormons believe that earthly religious ordinances must be performed for all people, even for those who are no longer capable of performing those ordinances for themselves. Billions of people have lived on earth without ever hearing Christ’s name or coming to understand the sacrifice that He made for them. Would a loving or just God consign His children to hell simply because they never had to chance to believe in someone of whom they had never heard?
Ordinances available in Mormon temples for living Church members are also performed for those who have already died. Mormons routinely seek out the names of their ancestors and other deceased persons in order to perform the necessary ordinances for them. Temple marriage, sealings, and endowments are performed with someone symbolically standing in for the person who is deceased. (When someone symbolically stands in the place of another person, that is called doing work for that person by proxy.) Baptisms are also performed by proxy for the deceased.
The only reason that proxy work is done for the dead is because Mormons believe that we continue to live in the spirit world after our earthly body dies. When work is done for the deceased, Mormons believe that those individuals will have the opportunity to accept or reject the work done on their behalf. We have no way to know who will or won’t accept those ordinances, so temple work is performed for everyone who has passed on. To have someone who has passed on baptized by proxy does not commit that deceased person to accept a “Mormon baptism.” Instead, it merely gives that person the opportunity to accept or reject the ordinance as they choose.