Thanos was killed twice in the movie. He was beheaded by Thor with the Stormbreaker in the opening scenes and then he was snapped out of existence by Iron Mark at the ending. He did not return to life but rather had a pym particle stolen for him by the 2014 nebula, the he was able to travel to the future to defeat the avengers.
Every person that snapped out of existence in Avengers Infinity war were brought back when the Hulk snapped them back into existence. Dr Strange and his fellow Wizards brought every hero to the battle ground for the final war. At the end of the movie we lost Black Widow and Iron man, Captain America retired and Thor has given up the throne on Asgard to Valkary.
you must have watched this movie before you can actually get all question here correctly.