In universe there are two explanations I can think of with the first being the most likely.
He picked it up
When Thanos is fighting with Thor, Thor throws Thanos’ sword away, the camera spins around a bit before Thanos sends Thor flying so it’s not exactly clear where he lands. It’s very possible that Thor lands near the sword. After being hit by Mjolnir Thanos falls to the floor slightly and stands up holding his sword again. It seems quite likely that he just picked it up off of the ground when he got hit.
The sword can return like Mjolnir/Stormbreaker
It’s not exactly clear if it can return to his hand when called but watching the fight scene back again a few times he throws the sword and it comes back to him again. As said it’s not clear if this is to do with the way he throws the sword or if it’s a property of the sword. Its possible it could be a power of the sword, if so that’s certainly a possibility for how he got it back.
Out of universe we shouldn’t rule out the chance that this was an editing mistake though. It’s also possible there was a slight time skip of a few seconds when Thanos picks the sword up or something along those lines. There does appear to be a few small time skips in the fight scene which could explain it.