Like with the 20,000 or so people signing onto the International Brigade in Ukraine. That's a sizable chunk of their army. Has that always been the case?
Ok! This is a surprisingly fun^([citation needed]) question.
Foreign fighters - people who take part in other country's conflicts for reasons primarily other than material gain - are indeed not a new thing. If you go back to the early modern period or before, there's no real norms about fighting only for 'your' nation or state - fighting on behalf of other causes (like Crusades) or states was as much the norm as the exception. Armies were often made up of a surprisingly varied mix of soldiers - at the start of the Thirty Years War in the 1600s, for instance, Sweden was notable for the fact that Swedes made up the bulk of the soldiers fighting on the Swedish side, and even then, by the end of the period Swedes made up a much, much smaller proportion.
It's only really the emergence of nationalism (and other -isms) in the late eighteenth century that allows for a distinct phenomenon of people fighting solely for abstract beliefs to become noteworthy. Among the earliest examples are American revolutionaries like the Marquis de Lafayette, of Hamilton fame, who fought for the American rebels because he believed in their cause. In the decades afterwards, there are other less clear-cut examples - plenty of British veterans of the Napoleonic Wars, for instance, became involved in Latin American wars of independence. They occupy a grey area - they were undoubtedly motivated by pay and opportunities not available in a peacetime British military, so material concerns weren't irrelevant, but they also did tend to be invested in the cause as well.
It's not until the 1820s that the archetype is solidified, when Lord Byron decided to volunteer to help the Greeks in their war of independence from the Ottoman Empire. Byron was both famous and rich, and not only did he help to inspire a wave of volunteers from across Europe (typically well-educated young men who had been taught to value Ancient Greek civilisation), he also spent massive sums of his own fortune in supporting the Greek cause. His actual battlefield contributions were forgettable - he bungled the few encounters he was involved in, and died of disease soon after - but the idealistic and romantic gesture he made resonated. It was not uncommon for other emotionally-charged conflicts of the era to attract volunteers, such as Garibaldi's campaigns to unite Italy (or the Papal States' efforts to resist the same). This was a tradition that continued all the way up to the first World War, where the Garibaldean 'debt' to France was repaid through the contribution of a battalion of Italian volunteers who fought on the Western Front before Italy even joined the war.
The high point of the phenomenon came somewhat later though, in Spain during the 1930s. A failed military coup in 1936 led to a brutal civil war that was swiftly subsumed into the tense politics of the 1930s. Spain became a flashpoint in the struggle against European fascism, and was seen as the first European country to openly resist a fascist-backed effort to overthrow a democratic government. As a result, it became immensely attractive to both people who had gone into exile from places like Germany and Italy, and also people who feared a fascist attack or takeover at home. Approximately 35,000 men and women from all around the world went to defend the Spanish Republic as part of what became known as the International Brigades, representing the largest single mobilisation of foreign fighters in the twentieth century. As in Ukraine, they represented a small fraction of the total number of soldiers engaged, but claimed an outsized proportion of media and historical attention ever since. They certainly didn't win the war (not least because their side lost), but the contributed significantly to the political and actual war effort. I have a few existing answer on them here.
Spain - and Ukraine - was highly unusual in this regard. Many twentieth century conflicts have seen some foreign volunteers take part, but usually on a negligible scale - maybe a few dozen or a few hundred. The Israeli War of Independence in 1948 is another notable exception, with the new Israeli Air Force in particular notably reliant on foreign pilots and technicians in its early years. Thousands of volunteers also flocked to Afghanistan in the 1980s, though it's much more dubious as to how many actually crossed the border and fought in any meaningful sense, though those that did went on to form the cadres of future insurgencies and terrorist movements in places like Bosnia and Chechnya. Their legacy has received renewed attention thanks to the more recent mobilisations in Syria, but this is beyond the scope of this forum.
In other words, foreign volunteering is rarely popular. For a conflict to be attractive, a few stars need to align. It needs to be a cause in which the stakes seem to go beyond borders - whether it's romantic nationalism, anti-fascism or pan-Islamism. There needs to be communities of people who are predisposed to act in the name of this cause, for reasons that can be viewed as extensions of their existing lives and commitments. There needs to be organisation - people or institutions willing to recruit, organise and lead contingents of foreigners. Above all, there needs to be purpose: it needs to be a battle in which individual sacrifice appears to matter, offering the (perhaps delusional) hope that one person might make a meaningful imprint upon history. These stars have rarely aligned in modern history, but it has certainly happened before, and as indicated by the terminology you used in the question, historical examples of 'International Brigades' still inform the way we see today's foreign fighters.
Sources
The best single book on this topic is Nir Arielli's From Byron to bin Laden: A History of Foreign War Volunteers (Cambridge, 2018). For the Garibaldinism phenomenon, Enrico Acciai's Garibaldi’s Radical Legacy: Traditions of War Volunteering in Southern Europe (1861–1945) is excellent too. If for whatever reason you want a political science perspective, David Malet's Foreign Fighters: Transnational Identity in Civic Conflicts (Oxford, 2013) exists.