By the late 14th/15th century, most Italian cities relied on professional troops - be they condottieri or directly employed. This was in large part due to the fact that militias had grown quite unreliable thanks to intense feuds between patrician families as well as all kinds of gradual exemptions acquired by the citizens.
Hence why almost all commanders in late medieval Italian armies were mercenaries. Usually appointed by whichever institution held overall executive power in each city, they were foreign in large part due to the internal feuds preventing effective cooperation between the aristocratic families. The most common case was that of a single large condottiere company providing a large majority of a city's troops, often in regular service, so the commander of said company was generally also the commander of the state's armies in war. Even if there were multiple condottieri in employ, the largest and most regular contractor was usually put in charge. Even troops directly in the government's employ were usually commanded by outsiders.
This practice led to an extreme in some cases - a single mercenary captain might acquire so much de facto power so as to set himself up as tyrant in all but name.