I see these statistics where an army will fight a battle at the beginning of their conquest with 50k men and lose tens of thousands throughout the campaign. Then at the end of the campaign hey have 40-50k soldiers. How does this happen?
By a multitude of methods, which I shall detail below.
Mercenaries-While the Romans and Alexander were less reliant than other armies, mercenaries played a huge part in the ancient world. Carthage, for example, was largely reliant on mercenary soldiers, and actually fought a small war against their own mercenaries at the end of the First Punic War due to a disagreement over pay. The Diadochi Wars for Alexander's kingdom after his death also involved large numbers of mercenaries on all sides.
Levy- This is one of the most common methods of raising troops. A Roman general would at the beginning of the campaign send a herald out to the allies and surrounding cities and tell the cities they needed to provide troops for the war. All the troops (including the ones from Rome itself) would meet at a predetermined place at a predetermined time and then head out as an army. When a city was conquered or allied itself with Rome, it would be required to send troops when requested. This was particularly common mid campaign during wintering, where an army would stay a city for the winter and request reinforcements from the surrounding areas before setting out again in spring.
Volunteers-Sometimes when a city saw that their situation would improve by joining Rome or Alexander, they would declare allegiance and send a contingent of troops as a sign of their dedication and goodwill. More often than not, these troops were readily accepted, but the Romans often times sent the troops back with gratitude. Individual soldiers from cities would also run off and join armies sometimes when the prospects of loot were large.
Switching sides-After a hard fought battle or siege, an army would be given the opportunity to desert the losing side and be integrated into the ranks of the winning side. This happened quite often in the Diadochi wars, where Macedonians were fighting Macedonians. The losing troops were taken in and distributed among the winning troops. Commanders could also be bribed to switch sides instead of fighting, which would greatly increase the overall numbers of a particular army.
There are a lot of other ways as well, but the ones I have listed are the ones that are spoken of most often. Hope this helped.