She showed up to save Tony because the Avengers presumably sent her (after they called her in the Captain Marvel mid credits scene, which they probably should have included in Endgame.)
They couldn't have sent her. None of the other Avengers knew where Stark, Parker, and Strange went. The closest we could get to that is Banner having seen Stark and Strange fighting these guys, but that's still pretty flimsy
unless Captain Marvel already knew who the Black Order was, knew they were connected with Thanos, and went to Titan looking for Thanos, but not looking for Quill's ship -- and found Stark and Nebula just incidentally while she was looking for Thanos. But no way the Avengers "sent" her out there to get Stark. They couldn't have known that's where he was.
As far as the time travel element goes, the film explains that: alternate timelines. You can't go back in time within your own timeline. Imagine you have a time machine that's just a button that sends you one half second into the past in your own timeline. Better not push that button, because if you do, you'll timelock yourself. Why? Because if you push that button, you'll go back to the exact instant where you haven't closed the circuit yet. You can't go back any further than that, because further back than that, the machine isn't sending you back. You can't go forward anymore, either, because you can only go as far forward as the point where the machine is sending you backward. You put yourself in an inescapable temporal headlock and trap yourself in that exact moment, unable to go forward or backward.
The movie offers a workaround for the Grandfather Paradox (which Volpone apparently
totally misunderstood, by the way): The Grandfather Paradox actually goes like this:
If you go back in time and kill your own grandfather before he has children, your father won't be born. If your father isn't born, neither will
you be born, which means you never exist and never go back in time to kill your own grandfather. Simply, you can't do it. Not within your own timeline, anyway, but I covered that bit above.
Thus, alternate timelines, You
can go into the past of an alternate timeline, kill the
alternate version of your grandfather -- but that only prevents the birth of the
alternate timeline version of you, not the version of you that does the deed.
Your grandfather hasn't been affected at all; he's part of your past and can't be affected in any way by you. (Of course, a version of you from an alternate timeline could come along and retroactively wipe you out without affecting himself, too. This gives me a story idea.)
So when the Avengers go back in time to collect the Infinity Stones, it's not
their timeline's version of the Infinity Stones. That 2014 Thanos that comes to 2023 isn't the same Thanos they fought in Infinity War; it's an alternate version. They already fought "their" version, this is a new (but basically identical) version.
[Nebula is fitting a time travel suit onto Clint Barton]Banner: Clint, now you're gonna feel a little discombobulated from the chronoshift. Don't worry about that.
James Rhodes: Wait, wait, wait a second. Let me ask you something. If we can do this, you know…go back in time, why don't we just find baby Thanos, you know, and…
[makes a gesture of strangling a baby with a rope, complete with "choking sound"]
Banner:
[disgusted] First of all, that's
horrible.
Rhodes: It's
Thanos.
Banner: And secondly, time doesn't work that way. Changing the past doesn't change the future.
Scott: Look, we go back, we get the stones before Thanos gets them? Thanos doesn't have the stones. Problem solved.
Clint Barton: Bingo.
Nebula: That's not how it works.
Barton: Well, that's what I heard.
Banner: Wait, but who? Who told you that?
Rhodes:
[counting with his fingers] Star Trek,
Terminator,
Timecop,
Time After Time…
Scott: …
Quantum Leap…
Rhodes:
Wrinkle in Time,
Somewhere in Time…
Scott:
Hot Tub Time Machine...
Rhodes:
Hot Tub Time Machine,
Bill and Ted's Excellent Adventure, basically, any movie that deals with time travel.
Scott:
Die Hard? No, that's not one.
Rhodes: This is
known.
Banner: I don't know why everyone believes that, but that isn't true. Think about it. If you travel to the past, that past becomes your future. And your former
present becomes the
past, which can't now be changed by your new future…
Nebula: Exactly.
Scott:
[confused] So,
Back to the Future is a bunch of
bullshit?
Actually, the only thing bullshit about BTTF is that 1985 Marty McFly went back to 1955A -- because as I explained way up top there, he
can't have gone back within his own timelilne -- and went forward again -- to 1985A. There should have been a 1985A Marty McFly already there, one who had grown up with 1955A's George and Lorraine McFly.