It was narrated from Samurah that the Messenger of Allah (ﷺ), said:
"If two (separate) authorized persons make a sale (of the same thing), then the first transaction is the one that is valid. " (AR)
English reference (AR): Vol. 3, Book 12, Hadith 2191 (AR)
Arabic reference (AR): Book 12, Hadith 2275 (AR)