Spoiler for Avengers: Endgame
While creating their own Infinity Gauntlet presents challenges, they face even greater challenges in attempting to duplicate the Infinity Stones. Not only do they travel to some of the major events of the past films including Age of Ultron, Thanos discovers their plans and decides to hunt them down.
However, Doctor Strange saw this possibility and placed spells on the Time Stone that trap Thanos at the time of the first Avengers film during the Invasion of New York.
With Thanos trapped in the past and understanding the consequences of affecting the past, the Avengers continue to seek out the other Infinity Stones. They even visit the Ancient One to get their hands on the Time Stone.
The Avengers will eventually run into Captain Marvel during the third act, but her power has been significantly reduced to Thanos’ attack earlier in the movie.
Thanos will eventually confront the Avengers on Xandar. Thanos’ power is still near unstoppable. It takes all of the Avengers to hold him back while the Hulk attempts to bring back those who were wiped out by Thanos.
However, Hulk’s arm explodes before they are able to defeat Thanos. Captain America then takes control of the Infinity Gauntlet and uses it to defeat Thanos, but also bring back all of his fallen comrades and those who were wiped out by Thanos’ snap. However, his body can’t handle the power and he ends up disintegrating.
While Captain America brings back the Avengers who were wiped out by the snap, it does not appear he brings back Gamora. She supposedly remains dead.
Captain America’s sacrifice not only defeats Thanos, but it also destroys the Infinity Stones. However, with the destruction of the Infinity Stones, a cosmic entity is freed that will more than likely be the next major threat the Avengers will have to face.
The film ends with Captain America’s funeral and Tony Stark announcing his retirement.