He hath brought many captives home to Rome,
Whose ransoms did the general coffers fill.
Did this in Caesar seem ambitious?
When that the poor have cried, Caesar hath wept;
Ambition should be made of sterner stuff.
Yet Brutus says he was ambitious,
And Brutus is an honorable man.
This passage from Julius Caesar doesn't reflect actual ancient Roman practices very well, but it does say something about the understanding of captivity and ransom in Shakespeare's England. It's hard to say whether Shakespeare genuinely did not know this about Roman captivity, and it's feasible he did know and made a deliberate decision to introduce an anachronism -- there are certainly instances of Shakespeare disregarding historical particulars in his plays either because he doesn't know or doesn't care, like having Hector the Trojan prince namedrop Aristotle in Troilus and Cressida. Similar to the references to ransomed captives (and chiming clocks) in Julius Caesar, this reference is handy for Shakespeare as a writer more interested in characterization and being understood than in strict historical accuracy the way modern writers might know it, and handy for his audience as an illustration of concepts set in terms immediately familiar from Early Modern English life. In England's ongoing conflicts with Spain and in conflicts in the Mediterranean, individuals on all sides became prisoners of war upon capture, and the idea of imprisoned Englishmen being sold into slavery in Spanish or Turkish territory seized the Elizabethan imagination as a way of immediately evoking foreign barbarity and hardship exceeding the "favourable" treatment of Spanish prisoners in English territory. The idea of prisoners being detained and ransomed back for a price proportionate to their status would be more familiar to English audiences and more compatible with their idea of an orderly state than the idea of keeping prisoners of war as permanent or long-term slaves. (Unless those prisoners of war also happened to be black -- Casper van Senden, an associate of Elizabeth I, did at one point propose reappropriating the black prisoners taken during a recent Spanish conflict and taking them back to the Iberian peninsula to sell into slavery, possibly back into slavery, to fund the ransom of English prisoners currently held there.)
The Shakespeare play that deals the most with the concept of ransom might be Henry V, where the prospect of capture in battle is present in a very immediate way and the choice isn't between ransom and slavery but ransom and a swift death -- all parties are aware that the potential for a lucrative ransom separates high-ranking prisoners from their inferiors, not only raising the financial stakes of victory or defeat but widening the gulf between rich officers and poor soldiers. The negotiation of ransom gets played for drama in Act 4 Scene 1/Act 4 Scene 3 and for comedy in Act 4 Scene 4 and in plenty of other scenes besides -- it's a versatile image and Shakespeare returns to it enough to suggest he saw it as a normal and pretty ubiquitous procedure during wartime. It's an aspect of the political landscape that Shakespeare assumes listeners are familiar with, and he applies it in roughly the same way in both plays set in Classical contexts and plays set in more recent European historical contexts, even when this creates anachronisms. This kind of ransom is most lucrative when prisoners are very numerous, especially high-value, or both; not only to make money that way but to make enough money to swell the public coffers indicates success in battle, but Antony's framing this success not in terms of Caesar's individual glory or personal benefit but in terms of his service to the Roman state. There's a rhetorical purpose for this in the context of Antony's speech, but the rhetorical impact relies on a familiarity with English-style captivity for ransom rather than captivity for the purpose of short- or long-term enslavement. Already by the 16th and early 17th century, slavery in Europe looked quite different than it had in Roman times, and while Shakespeare's not uninterested in all the political dramas of historical conquest and captivity, he doesn't seem to be especially interested in a contrast between the historical reality of these things and the contemporary reality of them. The anachronism dramatizes a certain kind of military success (the lucrative kind) in a way that would be immediately recognizable to Shakespeare's audiences, even if it sacrifices a chance to reflect historical reality.