Hold up! 'The church'.. being added to here... is the church at Jerusalem. These are already saved people joining in membership to the church at Jerusalem.
These are people who were sealed by the Holy Spirit individually before being given the Holy Spirit 'in the midst' of their local church.
When 'the church' is in question.. you have to check what is being talked about. It's not 'all redeemed' unless it's about the final end church in the New Jerusalem.
Matthew 16:18 is of the local church.. because it is of the local church in Matthew 18:20. Jesus would not introduce the church one way and then contradict Himself later!
Receiving the Spirit at salvation happens BEFORE water baptism. A group receiving the Holy Spirit to become one of God's churches is a different kettle of fish.. but this group would have already been individually converted and baptised in water.
You gotta check the context! Just like the body in 1 co 12.. is actually the local body at Corinth.. NOT all redeemed.
Look at Peter's sermon closely he is not speaking to the ones in the upper room already filled with The Holy Ghost:
Act 2:14 But Peter, standing up with the eleven, lifted up his voice, and said unto them, Ye men of Judaea, and all ye that dwell at Jerusalem, be this known unto you, and hearken to my words:
Act 2:15 For these are not drunken, as ye suppose, seeing it is but the third hour of the day.
Act 2:16 But this is that which was spoken by the prophet Joel;
Act 2:17 And it shall come to pass in the last days, saith God, I will pour out of my Spirit upon all flesh: and your sons and your daughters shall prophesy, and your young men shall see visions, and your old men shall dream dreams:
Act 2:18 And on my servants and on my handmaidens I will pour out in those days of my Spirit; and they shall prophesy:
Act 2:19 And I will shew wonders in heaven above, and signs in the earth beneath; blood, and fire, and vapour of smoke:
Act 2:20 The sun shall be turned into darkness, and the moon into blood, before that great and notable day of the Lord come:
Act 2:21 And it shall come to pass, that whosoever shall call on the name of the Lord shall be saved.
Act 2:22 Ye men of Israel, hear these words; Jesus of Nazareth, a man approved of God among you by miracles and wonders and signs, which God did by him in the midst of you, as ye yourselves also know:
Act 2:23 Him, being delivered by the determinate counsel and foreknowledge of God,
ye have taken, and by
wicked hands have
crucified and slain: (Grammar here suggest unsaved and in need of the message being preached)
Act 2:24 Whom God hath raised up, having loosed the pains of death: because it was not possible that he should be holden of it.