Hello, I think this question is mainly answered in this post : https://www.reddit.com/r/AskHistorians/comments/156372/has_there_been_such_a_thing_as_a_mercenary_state/
As for Imperator : Rome, it is a game so the number of soldiers (both of armies and mercenaries) are exaggerated for gameplay purposes, even if during the long (27 years) Peloponnesian War the numbers of mercenaries increased because many cities being destroyed, many inhabitants of these cities turned into mercenarism to live.
The rich cities-states prefered to use strangers to the city (xenoi (ξένος) in greek ) that were mercenaries (misthophoroi , mistho being the salary ) to fight for them instead of their own citizens because the demographic issue caused by the deaths of citizens during the war was important.
Mercenaries were less used (but not uncommon for some specific roles, for example slingers from the Balleares Islands) when citizens armies, which the roman army is the best example of, became the norm.
Some more studies :
https://www.academia.edu/6176302/Ancient_Greek_Mercenaries
I will let someone else respond to the question of mercenaries in medieval times.