From vv. 18-19, it seems that David only took back what the Amalekites had previously plundered (and per verse 16, that was from the Jews and, lehavdil, from the Philistines):
יח וַיַּצֵּל דָּוִד, אֵת כָּל-אֲשֶׁר לָקְחוּ עֲמָלֵק; וְאֶת-שְׁתֵּי נָשָׁיו, הִצִּיל דָּוִד. יט וְלֹא נֶעְדַּר-לָהֶם מִן-הַקָּטֹן וְעַד-הַגָּדוֹל וְעַד-בָּנִים וּבָנוֹת, וּמִשָּׁלָל, וְעַד כָּל-אֲשֶׁר לָקְחוּ, לָהֶם: הַכֹּל, הֵשִׁיב דָּוִד.
So this might get into the question of whether, whenThe Gemara (Bava Kamma 114a) states that if a Jew rescues another Jew's property from a non-Jew steals somethingJewish bandit, he can be considered halachically to have "acquired" it. I'llwe have to look up sources on the subject. But if we assume that he does notthe original owner didn't give up hope of retrieving it, then this wasn't Amalekite property at alland therefore it has to be returned to its owner. This is cited as halachah in Shulchan Aruch, Choshen Mishpat 368:1. So the Amalekites never actually legally acquired whatever they had taken from Tziklag and other Jewish towns, and thus David was fully justified in taking it.what was originally his and his men's (Whereasand returning whatever was recognizable to its original owners). Whereas in Shaul's case: even if we grant that perhaps some of the Amalekite property was also previously plundered from the Jews or from other nations, it wasn't recognizable as such.)