Depictions of slavery in the ancient world typically portray it as lacking any racial/ethnic component. A person would not have been enslaved based on their race, but based on their misfortune of being conquered, or because of some debt or crime they had committed. It is often portrayed that they were not enslaved for being considered inferior, but were seen as inferior because they had been enslaved. Was this accurate? If so, how did that system transform into the intrinsically racist system of only holding Africans as slaves, that became infamous during the colonial era in the Americas and Europe?
You pose some interesting questions, and I hope to offer some relevant ancient and medieval references.
The ancient Greeks had several different words for slaves, one of which was associated with war booty(δμώς / dmōs), but also others such as ἀνδράποδον / andrapodon, "one with the feet of a man" in contrast to τετράποδον / tetrapodon, "quadruped", or livestock. Homer uses a variety of terms for slave. I do not know if a slave was ever called tetrapodon as a figurative expression. Concepts of race did, however play into the role of slavery in antiquity;
from Xenophon's Hellenica Book 1 Chapter 6 Section 14:
And when the Methymnaeans refused to surrender,—for there was an Athenian garrison in the place and those who had control of the government were partisans of Athens, —Callicratidas attacked the city and captured it by storm. All the property which it contained the soldiers seized as booty, but all the captives Callicratidas assembled in the market-place; and when his allies urged him to sell into slavery the Methymnaeans as well as the Athenians, he said that while he was commander no Greek should be enslaved if he could help it.
Denzinger and Hunermann state in Enchiridion Symbolorum: A Compendium of Creeds, Definitions, and Declarations of the Catholic Church that Pope John VIII commanded in 873 that all Christians who hold other Christians as slaves must set them free. This points to a trend in opposing slavery, at least in certain forms. Similarly, post-conquest, William the Conqueror's 9th of 10 laws for England was "I prohibit the sale of any man by another outside the country on pain of a fine to be paid in full to me," effectively removing them from international slave trade. See Douglas, English Historical Documents, 1042-1189. William appended to this rights and protections for freed slaves, "if he, who wishes to make his serf free, hand him over to the sheriff by his right hand in full assembly, he must proclaim him quit of the yoke of his servitude by manumission, and show him free ways and gates and give him arms, lance and sword; finally the man is made free."
Marek Jankowiak wrote an interesting paper Dirhams for slaves. Investigating the Slavic slave trade in the tenth century which traces silver Arabic coin hoards through Europe to try and provide a richer understanding of slavery in Europe, particularly regarding Arabic origins and intermediaries to European destinations.
According to Backhaus, and Georg's Liberation of the Serfs: The Economics of Unfree Labor, the Sachsenspiegel of the Holy Roman Empire condemned slavery as a whole in the early 1200s as "a violation of man's likeness to God." Backhaus and Georg argue that slavery is economically unfeasible long term, and therefore causes it's own demise.
As you mentioned, one source for slaves in antiquity was as prisoners from war. Brodman examines historical slavery with some comparison to modern rules of war for prisoners in Captives or Prisoners: Society and Obligation in Medieval Iberia, which can be freely viewed here
Miller in The French Atlantic triangle: literature and culture of the slave trade cites a decree from Louis X among his Ordonnances des Roi de France in 1315 that "as soon as a slave breathes the air of France, he breathes freedom". He also allowed serfs to buy their freedom.
Concerning the discovery of the New World, Miller writes in The International Law of Discovery, Indigenous Peoples, and Chile
In May 1493, Pope Alexander VI issued the papal bull Inter caetera, ordering that the lands, which “hitherto had not been discovered by others” and were found by Columbus, now belonged to Ferdinand and Isabella along with “free power, authority, and jurisdiction of every kind.” The Pope also granted Spain any lands it might discover in the future “provided however they at no time have been in the actual temporal possession of any Christian owner.” In addition, since Columbus had reported that the native peoples were well disposed to embrace the Christian faith, the Pope exercised his universal guardianship authority and placed these indigenous peoples under the tutelage and guardianship of Spain....in 1495, Columbus violently suppressed a native revolt, sold one third of 1500 captive Indians into slavery in Spain, and created a coerced labor program for mining purposes. He also established a feudally inspired tribute system for tribal leaders, or caciques, and any who did not pay were jailed. In 1499, a significant gold strike occurred on the island and large-scale pit mining commenced, so Columbus expanded the system of forced labor by “commending” groups of Indians to Spanish mine owners. As a result of Columbus’ actions, “thousands of Indians died in resistance or in the mines.” When Queen Isabella learned of these events she was incensed at Columbus for making Indians slaves when they were her subjects and had been entrusted to her care by the Pope. Columbus’ governorship was terminated in 1500, and the Queen appointed a new governor, Nicolas de Ovando, with a mandate to end Indian enslavement and to indoctrinate the Indians into Catholicism. Yet, ironically, the Crown also ordered him, in 1501, to utilize a system of forced labor against the natives “to mine gold and to carry out the other works which we have ordered.” Even more sinister, the Crown issued a secret instruction to Ovando to force Indians to move to newly created Indian towns near the mines to increase gold production and to grow food and erect buildings for the Spanish; Ovando was authorized to “persuade” the Indians to do these tasks by force, if necessary. This system was called the encomienda, which means “to commend,” and as Columbus had done, groups of Indians were commended to various Spaniards as forced laborers."
Skipping forward in time, Boswell's The Life of Samuel Johnson mentions a case Somerset v Stewart in 1772 wherein Habeas Corpus, originally enshrined into law with the Magna Carta in 1215 was used successfully to argue that slavery had no place in English law. The presiding authority Lord Mansfield stated;
The state of slavery is of such a nature that it is incapable of being introduced on any reasons, moral or political, but only by positive law [statute], which preserves its force long after the reasons, occasions, and time itself from whence it was created, is erased from memory. It is so odious, that nothing can be suffered to support it, but positive law. Whatever inconveniences, therefore, may follow from the decision, I cannot say this case is allowed or approved by the law of England; and therefore the black must be discharged.
See also: Usherwood The Black Must Be Discharged - The Abolitionists' Debt to Lord Mansfield History Today Volume: 31 Issue: 3. 1981.