I saw a theory on YouTube that made a lot of sense and could account for the Sam of it all...
- At the end of Endgame, when Cap goes back to return all the Infinity Stones, he DOESN'T have his shield. He only has Thor's hammer and the Stones.
- Yet, when Old Man Cap then appears on the bench a few second later, he obviously has his shield again, which he then famously gives to Sam.
- That said, Cap went back to the '40s to be with Peggy AFTER the original version of him - and his shield - became frozen in ice. So in that timeline going forward, future Cap doesn't have his shield, while the original Cap and his shield are still on ice (meaning two Caps technically exist in that timeline, but that's neither here nor there).
- Regardless, then, during the events of Doomsday, Earth-616b Cap ("our" Cap, the one from the future) at some point almost assuredly crosses over/jumps ahead in time to Earth-616a and joins up with the Avengers (or the AvengerZ or whoever the hell) to take on Doom.
- It's at this point that Sam might give the shield BACK to Cap, at least temporarily.
- From there, the events of Doomsday and Secret Wars play out. And then, after both movies/events, Cap goes back in time to Earth-616b to be with Peggy and their baby, they all live a long, happy life, then, in his old age, Cap crosses back over to Earth-616a in 2023, takes a seat on that bench, gives Sam his shield back, and the same scene plays out, only now with way more context/background.
Does that make sense?
Basically, in this scenario, the same shield is traded back-and-forth between Cap and Sam in a time loop of sorts.
Granted, there would be a couple more details than that, and it might be hard to track for general audiences, but it would at least explain everything.