At the very end of “Avengers: Infinity War,” after all the credits have played, Nick Fury (Samuel L. Jackson) hits a button on a pager just as he melts into ash. The pager displays a yellow, eight-pointed star on a red and blue field. At the time, savvy Marvel fans recognized this as the symbol of Captain Marvel (Brie Larson), aka Carol Danvers, a character who would get her own prequel movie the following year.
A mid-credits scene for “Captain Marvel” continued the narrative. The remaining Avengers are seen investigating the mysterious pager, only to have the mystery quickly solved when Carol Danvers herself returned to Earth to respond to Fury’s distress call.
The next time we saw her was at the start of “Avengers: Endgame,” where she arrived just in time to save Iron Man (Robert Downey, Jr.) from dying in a derelict craft drifting in deep space. From the way “Endgame” is directed, it appears that Captain Marvel happened upon Iron Man by chance and decided to save him out of the goodness of her heart. It especially appeared that way to “Endgame” audience members who hadn’t seen “Captain Marvel” (or left when the credits started rolling). But Russo explains that there were unfilmed parts of the story, and that Carol finding Iron Man was no accident:
“The missing narrative, of course, is that she came to Earth, met the Avengers, was brought up to speed on what was happening, and that there’s some sort of homing beacon on that ship that she tracks, and brings the two of them back to Earth.”
Easy peasy. Captain Marvel got the page, went to Earth, the Earthbound Avengers let her know that Iron Man was lost in space, and Rocket (the only Guardian of the Galaxy who remained un-dusted) tipped her off to the Benatar‘s homing beacon.