The gates of hell can be understood in several different ways with “gates” referring to a city perhaps and hell referring to Hades which is divided into the abode of the lost “Gehenna” ( Luk 16:23) and the redeemed “Abraham’s Bosom”.
St. Peter being appointed as prime minister is an act of ordaining the office that is prophesied by the prophet Isaiah (Ch 22). As prophesied by Isaiah it is an enduring office that will remain for all times meaning that this same Church and the only Church founded on the rock of St. Peter will be present at the Parousia. This city on a hill that cannot be hid, meaning the Church, is well prepared by Christ to withstand the attacks from those demonic forces from Hades or the abode of the dead in Christ previously referred to as Gehenna before the gates of heaven were opened by Christ’s redemptive sacrifice. This is a sufficiently fortified city (Gen 22:17; 24:60; Isa 14:31, etc.) to withstand the spiritual warfare that will inevitably be fought by not only the demonic forces that oppose God but also those that do the will of evil because of their allowing themselves to be outside of His Church and influenced by false teaching that appeals to their own pride of the flesh and their itching ears. The demons and their human accomplices are opposed to that which is good such as the fullness of truth professed by the Church. The keys to this city or fortress against the attacks of Hell are given to St. Peter and thus the city or Church defends itself based on the teaching of the Church which is the “pillar and foundation of the truth”.
Another way of understanding the “Gates of Hell” is to understand that the Church is also on the offensive to rescue those who would be lost in the snare of Satan by the spread of God’s Word and the truth of the Gospel. But in either case it relates to Christ’s eventual and complete victory over evil by the Fortress of His Church. God bless!