The second possibility involves something superhero comics love to play around with: parallel universes. If you go back in time and change some stuff, you create an alternate version of the future that this version of you just hops into when you travel back to your present. It's a different present, because you've changed it, and because you've created an entirely new timeline branching off from the first. Schrödinger's cat can be alive, dead, a go-go dancer, or never even put into that box in the first place. The Marvel universe already operates according to the many worlds theory, which allows for all the parallel universes already in the canon. (The Marvel Cinematic Universe actually considers itself its own parallel universe, Earth-19999, distinct from our real world and the primary continuity of the Marvel comics, Earth-616.)
This is where Ant-Man comes in. As you know, if you've watched either or both Ant-Man and Ant-Man and the Wasp, when you get really teeny tiny you enter something called the "Quantum Realm," where stuff gets very blurry and technicolored. Time works differently in the Quantum Realm, which is why, when Ant-Man reemerges five years after The Snap, he hasn't aged more than a few hours. It's also why he and his technology are crucial to Endgame -- specifically, crucial to Tony Stark figuring out how to harness the power of the Quantum Realm and use it to transport himself and the rest of his buddies through time itself.
I’m not going to go into the mechanics of quantum time travel here because it's way too complicated. (Frankly, I did twenty minutes of Googling for this piece and I still don't understand it. If there's one thing I've learned from the Avengers, it's to embrace both my strengths and my weaknesses.) Basically, the general principles of quantum theory allow for every possibility to occur at any given time, which does away with any kind of paradox arising from time travel. The many-worlds interpretation of parallel universes rests entirely on quantum theory: every possible thing that could ever happen creates its own little bubble universe branching off from the main one. You can't change "the past," because whatever you do creates a new reality.
This is why everything Thanos did in Infinity War still affects the future, even if he didn't do it: by following the Avengers through time himself, he entered the parallel universe they created, which requires The Snap to exist. This is also why Captain America can trade blows with himself when he hops back to the Battle of New York without both of them ceasing to exist on contact.
And, yes, this does mean that somewhere out there there's a universe in which Thanos won forever and half of life is still ashes blowing in the wind. When Bruce Banner talks the Ancient One (Tilda Swinton's character from Doctor Strange) into handing over the Time Stone to him, their conversation touches a little on this wrinkle. By giving him the Time Stone, the Ancient One fears the timeline created by that alteration will sour, and everything will go bad way faster from that point on. Bruce convinces them that the plan is to return the Stones to the place they were taken from right when they were taken, and by the end of the movie we can assume that this happened successfully. It actually doesn't matter to the new timeline at all whether or not the Stones are returned (because… quantum stuff), but it's a nice little bit of altruism on the part of the Avengers. Hey, they're superheroes.