So like the question is a little ambiguous I'll rephrase it here: how did those empires so much equipment to equip their armies? Did they have some sort of "industrial-scale" factories? Or many craftmen doing the same thing independently?
For the Roman Empire, the answer is that weapons and equipment were mostly provided by the private sector. In the imperial period new units were always set up in Italy, "where they could take advantage of well-established Italian industries" (Herz p.314). The state paid the producers and handed over the equipment to the individual soldiers, who had the costs of the equipment deducted from their pay (over a period of a few years).
For the replacement of equipment the Roman military camps included workshops where repairs could take place and small numbers of simple weapons could be produced. Larger requirements again were provided by the private sector locally. The local private sector probably wouldn't be as large scale as in Italy (depending on where the unit was stationed), so it likely included any craftsmen who were up for the job. If no sufficient local supplier(s) existed, the military would create its own production site (as happened in Britannia).
Source:
Hello there! The Carthaginian republic seems to have operated its own arsenals (staffed by slaves), though the foreign mercenaries and native levies that formed the bulk of their overseas armies would have supplied much of their own equipment, at least initially. When P. Cornelius Scipio (later Africanus) captured Carthage in Spain ("New Carthage") in 209 B.C., he found two thousand slaves who had apparently been making war materiel for the Carthaginians and promised them freedom after the cessation of hostilities if they continued working for the Romans in the meantime (Polybius 10.17.9; Livy 26.47.2); in fact, according to Livy (26.47.6), Scipio's forces had seized "120 catapults of the largest size, 281 smaller ones, 23 larger and 52 smaller ballistae, [and] an enormous quantity of larger and smaller scorpions as well as arms and projectiles." Given that the Carthaginians were able to mobilize large and fully-equipped armies relatively quickly, scholars have naturally assumed that similar facilities existed elsewhere. [1]
The state also controlled shipyards. The Marsala shipwreck, a rather amazing discovery for underwater archaeologists, revealed that the Carthaginians assembled their vessels using prefabricated and probably mass-produced parts, as each component was numbered with an alphabetic construction mark. [2] Although scholars at the time were more interested in explaining how the Romans, using a captured warship as a model, were able to produce a hundred quinqueremes in sixty days at the start of the First Punic War, it also suggests in my mind some degree of central planning on the part of the Carthaginians.
I hope you find this helpful! :D
[1] Gilbert Charles-Picard and Colette Picard, Daily Life in Carthage at the time of Hannibal, transl. A. E. Foster (New York: Macmillan, 1961), 103f.; Yu. B. Tsirkin, "The Economy of Carthage," in Carthago (Studia Phoenicia VI), ed. E. Lipiński (Leuven: Peeters, 1987), 132f. See also Anna Chiara Fariselli, "The Impact of Military Preparations on the Economy of the Carthaginian State," in Phoenicians and Carthaginians in the Western Mediterranean (Studia Phoenicia 12), ed. Giovanna Pisano (Rome: Università degli Studi di Roma Tor Vergata, 1999), 59-67.
[2] Honor Frost, "The Prefabricated Punic Warship," in Punic Wars (Studia Phoenicia 10), ed. H. Devinyer and E. Lipiński (Leuven: Peeters, 1989), 127-35. See also Louis Rawlings, "The Carthaginian Navy: Questions and Assumptions," in New Perspectives on Ancient Warfare, ed. Garrett G. Fagan and Matthew Trundle (Leiden and Boston: Brill, 2010), 253-87.