Swiss law banned mercenary companies from 1848 and individual service as a mercenary in 1859 (you could still join a foreign national army provided you complied with your obligations for Swiss military service and you could get permission to join a non-national army - for example some served in King Leopold’s private army/atrocity service in the Congo) and all foreign military service without express consent from the Bundesrat from 1927 onwards . Exceptions in all cases for the Papal Guard (only).
They recently updated their laws in 2015 just to make it clear that they mean it. No more Swiss mercenaries (except the Swiss Guard because tradition!).
And because they class them as a ‘police force’
The end point of Swiss military superiority was apparently from about 1515 onwards but before then they’d been the terror of European battlefields right enough.
By then everyone had started copying and improving on what the Swiss were doing (and gunpowder weapons became more practical - still, pike formations made up the mainstay of infantry armies until, oh, some time after the Napoleonic Wars depending on what you count as a pike).
The whole historical phenomenon apparently gave us the medical condition ‘nostalgia’ or homesickness due to the alleged issues caused by dragging Swiss farmhands off their mountain farms and sending them off to fight in the plains of Italy or France, far from their cows (and cowbells).