When Jesus says that Peter is the rock and he will build the church on him… in Mat 16:18-19, does that mean that Peter is the foundation, or does it refer to his confession of faith, or both?
Both. Here are excerpts from the Catechism:
881 The Lord made Simon alone, whom he named Peter, the “rock” of his Church. He gave him the keys of his Church and instituted him shepherd of the whole flock. “The office of binding and loosing which was given to Peter was also assigned to the college of apostles united to its head.” This pastoral office of Peter and the other apostles belongs to the Church’s very foundation and is continued by the bishops under the primacy of the Pope.
424 Moved by the grace of the Holy Spirit and drawn by the Father, we believe in Jesus and confess: 'You are the Christ, the Son of the living God. On the rock of this faith confessed by St. Peter, Christ built his Church.
552 Simon Peter holds the first place in the college of the Twelve; Jesus entrusted a unique mission to him. Through a revelation from the Father, Peter had confessed: “You are the Christ, the Son of the living God.” Our Lord then declared to him: “You are Peter, and on this rock I will build my Church, and the gates of Hades will not prevail against it.” Christ, the “living Stone”, thus assures his Church, built on Peter, of victory over the powers of death. Because of the faith he confessed Peter will remain the unshakable rock of the Church. His mission will be to keep this faith from every lapse and to strengthen his brothers in it.