So time travel in the film is very different than a lot of other time travel films, I honestly can't think of one off the top of my head to compare it to. So the idea is that there is we have our MCU timeline, it is the main timeline and the center of it all. When you go back in time and change something, you create a branch. This branch becomes a new timeline, and basically allows our characters to do whatever the hell they want without consequence. When they travel back to the present, they are leaving the new branch and going back to the main base of the time stream. Here's a diagram to paint what it would kind of look like:
It's a little messy, but the idea is that anything connecting downward is one of these "branches" So the team who goes to 2014 created a new branch, and that branch's Thanos is the one traveling to the main timeline. This is why killing him has no effect on anything. It's why Loki is able to escape and everything is fine. But using these rules the film contradicts itself a couple of times.
1) Steve shouldn't be on that bench at the end. The film doesn't state it's an alternate Steve so that's not an explanation, it's our Steve we've been following. It's possible that he traveled back, but if he did he should've come back through the tunnel.
2) The Ancient One says the stones must be returned to their place in time because they hold the fabric of reality together. This is can't be true because they can be destroyed without consequence.
3) Thanos shouldn't have been able to travel to the main time line without the Pym Particles. Evil Nebula would've had to use the last of their supply to return in the first place.
4) Steve shouldn't be able to return the past stones to the where they got them. The film makes clear that they can only travel to points within their past, so he'd only be able to return to the original variation of the past films' events, eliminating the possibility to return the stones.
All in all, it's not the worst or most confusing of time travel, but personally I'm not a fan. It definitely cheapened a lot and made that aspect of the film feel inconsequential.