I know there's a 'SPOILERS' thread, but I think that time travel in "ENDGAME" deserves its own thread, because it's complicated. I must say that it's even an original approach.
INFINITY WAR: basically, if Strange tells Tony they're in the right timeline before everything that needs to happen happens, it won't happen. Strange holding up the one finger is a signal to Tony that everything that needs to happen for them to win has happened, they are in the one timeline. If Strange had told Tony before this, those things wouldn't have happened. He saw 14 million futures. He knows exactly how this needs to play out.
As for the time travel in ENDGAME, Hulk and the Ancient One make clear that you can't change the past. By changing things, you're just creating another timeline. Your past is your past, you can't change it. So even if Cap were to change things in his new life with Peggy, it wouldn't affect the main MCU timeline. The Gamora from 2014 running around in 2023 doesn't affect the Gamora we followed in GOTG 1-2 and infinity War. She still lived and died. The new Gamora is one from a different timeline. So if Cap were to change anything, it wouldn't affect the main MCU timeline.
Easiest way to explain it is this:
Main timeline: The one the MCU follows and is in now and will continue to follow.
Timeline 2: Everything the same up until the Battle of New York. Loki escapes with the Tesseract, Captain America and Hulk steal the Mind and Time stones. Cap later returns these stones to the moment they were taken, restoring this timeline almost to normal (Loki is still on the loose with the Tesseract).
Timeline 3: Everything the same up until "Thor: The Dark World". Rocket removes the Reality stone from Jane. Cap later returns the stone at the moment it was taken. This alternate timeline is erased and restored to the main timeline.
Timeline 4: Everything same up until the 1970's. Tony steals the Tesseract from SHIELD. Cap later returns the Tesseract. This alternate timeline is erased and restored to the main timeline.
Timeline 5: Everything same up until GOTG. Rhodey and Nebula steal the Power stone while Nat and Clint retrieve the Soul stone. The Thanos, Nebula, Gamora and Thanos's army of this timeline travel to Main Timeline, where Thanos, Nebula and Thanos's army are killed. Cap later returns the stones but this timeline goes forward without Thanos, Nebula and Gamora.
Timeline 6: Captain America goes back to the 40's and lives a long and happy life with Peggy. Cap returns to the main timeline to say farewell to Bucky and Sam after Peggy presumably dies.
As is made clear in the film, you cannot change the past. The past remains the same no matter what. The time travel rules from other movies don't apply to the MCU. Instead, you create a different timeline. The timeline you originated from still exists. The changes the Avengers make in the past have no effect on the future they came from.
Radically DIFFERENT approach from the Fox X-Men Main Universe, where the timeline is revised twice and we got three timelines for the same universe:
Timeline 1: X-Men Origins: Wolverine; X-Men; X2; X-Men: The Last Stand; Logan.
Timeline 2: X-Men: First Class; revised movies; The Wolverine (2008); Days of Future Past 2023.
Timeline 3: X-Men: First Class; Days of Future Past 1973; X-Men: Apocalypse; Dark Phoenix; The New Mutants; DOFP New 2023.
The Deadpool movies are set in an alternate universe.