The term gates of hell and similar is used a lot in the Old Testament
Have the gates of death been shown to you, or have you seen the gates of darkness?—Job 37:17
Have mercy on me, LORD; see how my foes afflict me! You alone can raise me from the gates of death.—Psalm 9:14
They loathed all manner of food; they were at the gates of death.—Psalm 107:18
Once I said, “In the noontime of life I must depart! To the gates of the nether world I shall be consigned for the rest of my years.”—Isaiah 38:10
For you have dominion over life and death; you lead down to the gates of the nether world, and lead back.—Wisdom 16:13
and cried out in a very loud voice, imploring the Ruler over every power to manifest himself and be merciful to them, as they stood now at the gates of death.—3 Maccabees 5:51 (non-canonical)
my soul had been well nigh poured out unto death, (I had been) nigh unto the gates of Sheol with the sinner—Psalms of Solomon 16:2 (non-canonical)
‘a solidly built city, founded on rock, [that] protects from the power of chaos and the “gates of death”’.—1QH 6.24–26 [from the Dead Sea Scrolls] Schnackenberg Matthew, p. 159.
Also, the phrase “gates of hell” in Matt 16 has also been translated as “bars of sheol” in the Diatessaron, and the early Syrian Fathers, and some ancient texts and translation of the scripture refer to the gates of hell not prevailing against Peter.
" But Samson lay till midnight, and at midnight he arose and took hold of the doors of the
gate of the city and the two posts, and pulled them up, bar and all"–Judges 16:3
Father Murray’s book Symbols of Church and Kingdom also has a discussion on the interpretation of gates of hell “bars of sheol.” He claims that phrase can potentially be understood “the bars of sheol will not be able to withstand her.” Her being the Church.
From what I’ve read the Church Fathers universally (Latin Greek and Syrian) understood “gates of hell” to refer to heresies, that they will not prevail. Many Fathers also refer to Christ smashing the Gates of Hell, and consequently the Church does likewise.
Here is part of Cornelius Lapides’ Commentary:
The gates of hell, i.e., the infernal city, meaning all hell, with its entire army of demons, and with the whole power of Lucifer its king. For hell and the city of God, i.e., the Church, are here put in opposition. When S. Augustine wrote his work de Civitate Dei, in the beginning of which he speaks of the two opposite cities; the one of God which is the Church; the other of the devil, i.e., of demons and wicked men: he takes the gates of hell to mean heresies, and heresiarchs; for they fight against the faith of Peter and the Church, and they proceed from hell and are stirred up by the devil. So S. Epiphanius (in Ancoratu), not far from the beginning. There are here the two figures of speech—synecdoche and metonymy; for by the gates he means the whole city, both because the gate is the entrance into a city, and because the chief defences and strength of a city are wont to be at the gates, because if they and the adjoining walls are safe, the city is safe, if they are taken, the city is taken
Shall not prevail. Heb. lo juchelu la, i.e., shall not be able to stand against it—namely, the Church. So S. Hilary and Maldonatus. More simply, shall not prevail, i.e., shall not conquer or overcome, or pull down the Church. For this is the meaning of the original Greek. We have here the figure of speech, miosis: for little is said but much is meant; not only that the Church shall not be conquered, but that she shall conquer and subdue under her all heretics, tyrants, and every other enemy, as she overcame Arians, Nestorians, Pelagians, Nero, Decius, Diocletian, &c. Therefore by this word Christ first animates his Church that she should not be faint hearted when she sees herself attacked by all the power of Satan and wicked men. In the second place, He as it were sounds a trumpet for her, that she may always watch with her armour on against so many enemies, who attack her with extreme hatred. Thirdly, He promises to her, as well as to her head, Peter, i.e., the Pontiff—victory and triumph over them all. …
I’ve also seen many today claim the “Gates of Hell” is a cave near where Jesus was speaking that had a statue of pagan god Pan, where pagans believed
Another explanation seems to be that the phrase comes from the idea that strongest part of an army is located at the city gate, therefore it seems as if a defensive barrier is being used for offensive purposes. It simply means the greatest power of death will not be enough to destroy the church.
IF my post was too long, too bad.