The phrase “gates of Hades” is a common Semitic expression for the threshold of the realm of death (11:23; Rev 1:18). The phrase can be found in the both the Old Testament and apocryphal writings (Job 38:17; Isa 38:10; Wis 16:13; 3 Macc 5:51), and in later Jewish literature (1QH 6.24). Here, though, the interpretation is a bit more dubious. Gundry argues that given the prominence of persecution in the gospel, Matthew is probably using the phrase to represent death by martyrdom. Even in the face of the apostles’ bloody deaths, then, the church will still remain victorious. Other commentators, such as Jeremias, lean towards the πύλαι ᾅδου serving as the forces of the underworld. Given the usual understanding of the phrase, it is probably best taken as meaning “the power of death” or simply “death.
Cf. Mt. 16:21
"From that time Jesus began to show His disciples that He must go to Jerusalem, and suffer many things from the elders and chief priests and scribes, and be killed, and be raised up on the third day." Christ will be victorious over death!
"shall not overpower" - κατισχύω, which means “to win a victory over.” In other words, the power of death will not win a victory over the church. It makes sense that the antecedent for αὐτῆς refers to ἐκκλησία rather than πέτρα since “church” is closer in proximity. Therefore, the church, as an eschatological community, will never die or come to an end. As Keener states: “The church will endure until Jesus’ return, and no opposition, even the widespread martyrdom of Christians … can prevent the ultimate triumph of God’s purposes in history.