If the Holy Spirit has something to do with every aspect of Mormonism, then what does He have to do with Mormon baptism?
You are learning to ask clever questions! Okay, here is the answer to your question: Although we are baptized for the remission of sins, the actualy remission of sins comes by the power of the Holy Ghost, and that remission may even precede baptism. The
intent is sufficient to bring about the remission of sins by the power of the Holy Ghost, even prior to baptism taking place, as shown by the second quote:
D&C 19:
31 And of tenets thou shalt not talk, but thou shalt declare repentance and faith on the Savior, and remission of sins
by baptism, and by fire, yea, even the Holy Ghost.
D&C 20:
37 And again, by way of commandment to the church concerning the manner of baptism—All those who humble themselves before God, and desire to be baptized, and come forth with broken hearts and contrite spirits, and witness before the church that they have truly repented of all their sins, and are willing to take upon them the name of Jesus Christ, having a determination to serve him to the end, and truly manifest by their works that they have
received of the Spirit of Christ unto the remission of their sins, shall be received by baptism into his church.
This is not the same as the gift of the Holy Ghost that is given by the laying on of hands after baptism.