In this scene from Avengers: Endgame (2019), we see Steve Rogers handing an intact version of Captain America's vibranium shield to Sam Wilson. How was the shield intact after what Thanos did to it in the Battle of Earth?
Shortly before the scene you mentioned, the younger version of Steve went back in time in order to return the Infinity Stones and Mjolnir to the time periods and places the Avengers borrowed them from, earlier in the film. Once he'd done that, he was supposed to come straight back to the present (2023), but apparently chose to travel to the 1940s instead, so that he could marry and settle down with Peggy Carter.
According to the directors of the film, Joe and Anthony Russo, when Steve went back, he created a branched reality in which there was another Cap who was still frozen in ice, following the events of Captain America: The First Avenger (2011). He then married and settled down with Peggy Carter in this branched reality, before using a Pym Particle to return to the main MCU timeline in order to hand the shield to Sam.
KEVIN MCCARTHY: When Cap goes back, where is the Cap in that world? So when he goes back to the early days, is there still another Captain America in that world?
JOE RUSSO: The way that it would work is that when Captain America goes back, he would create a branched reality. Now he would exist in that branched reality with a second Captain America who was frozen in ice.
KEVIN MCCARTHY: So did Peggy not know that other Cap?
JOE RUSSO: Well, that other Cap is frozen in ice.
ANTHONY RUSSO: And Peggy understood that he was dead at that point in the storytelling, 'cause Cap went back to a point in time where nobody knew he still was alive, frozen in ice.
JOE RUSSO: What's also a story for another time is if he created a branch reality, he would then have to use a Pym Particle to come back to this reality to hand that shield off.
Steve went back in time without the shield, so if he created a branched reality when he travelled to the 1940s and then returned from that reality with a shield, it follows that the shield was from the branched reality. This makes a degree of sense, as bringing the shield over from another reality (and marrying Peggy there) wouldn't contradict the established history of the main MCU timeline.
Also, the shield given to Sam at the end of the film looks slightly different than the one Steve had previously; specifically, the silver star in the centre and the silver ring have additional markings on them that weren't there before. We don't know what the story is behind that, but it's easier to think of possible explanations if the shield is from another timeline rather than the main MCU timeline.