Thank you for the scripture.

Here’s the thing, I’m reading chapter 16 and its not an easy chapter. And this is one thing that I find striking.
Lets suppose that you are correct and he is declaring Peter to be infallible (and his successors) and that they are the foundation for the church.
Right after that, Jesus yells at Peter and tells him that he is basically fallible:
“Get behind me, Satan! You are a stumbling block to me; you do not have in mind the things of God, but the things of men.”
So its a bit odd. If the interpretation you are suggesting is what is meant. It is odd that he would declare Peter to be the foundation of the church and then tell Peter what an idiot he is. That would be akin to Jesus saying he was founding his church on an idiot.
What comes off the page for me is that Peter makes a confession of faith in Jesus and then Jesus says upon this rock he will build his church. To me, he is saying that upon Peter’s faith and confession he will build the church. And it seems to me that hell cannot prevail against this faith. So it is the faith that the church is built upon.
Then you have the issue of the keys, which I presume to be a metaphor, and not literal keys to heaven which Jesus says will bind in heaven what he binds on earth and loose in heaven what he looses on earth.
Which I take to mean the faith again, which will either deliver one to heaven, or it will not if you lose it.
And I think that is correct because the last bit of the chapter Jesus says that each person will be rewarded for what he has done.
So it seems to me that the most important thing here is faith in Jesus. And it is this faith that guides and protects the church. Not that Peter or any bishop has some mystical power to be free from all errors.
And in fact, if Jesus sends his Spirit to those who believe in him, then it is the Spirit that is keeping the faithful (out of Hades) and not a particular bishop.