I am excluding volunteers who were sent by their government, such as the troops sent by Nazi Germany and Italy. I wish to learn more about those who came of their own free will because they supported the ideals of either side. How were they organized? Did they just show up to Spain and ask to enlist? And why did the Spanish civil war attract so many foreign volunteers in the first place?
You've asked a few big questions there! I'm going to kind of blend them all together, since they are all somewhat connected.
One of the crucial things about the foreign volunteering phenomenon in Spain is that it happened in waves. Many of the earliest foreigners who fought were either already in Spain when the conflict broke out, or made their way there using their own means or informal networks, and this remained the norm in the first few months of the conflict. This meant that the initial wave of volunteers could be quite heterogeneous, covering not just idealists (for a quite varied set of ideals at this point) but also mercenaries and adventurers who saw the conflict itself as the opportunity rather than the political stakes. Those who made it to Spain integrated themselves into the haphazard structures of the Republican forces as best they could, generally by attaching themselves to whatever militia column best reflected their beliefs and/or would take them. It's important to remember just how chaotic the Republican state and armed forces were in these crucial early weeks - there was no formal centralised process, and getting to fight was more about convincing local militia, political party or trade union leaders that they should trust you and let you join them.
However, in autumn 1936, volunteering started to change drastically. This was partly due to the Republican Government gradually re-establishing itself as a cohesive state, but mostly because the Soviet Union made a decision to actively intervene to support the Republic. Part of this intervention involved selling arms and supplies, providing a safe(ish) home for Spanish gold reserves to finance further overseas purchases and sending military advisors and specialists. For our purposes though, the key decision was that instead of trying to send an entire army to Spain to fight - which Stalin had little desire and most importantly limited capacity to do - they would try and facilitate the recruitment of international volunteers with military experience to bolster the inexperienced and poorly (barely) trained Spanish militias.
This decision was significant because the USSR had spent much of its existence building an international network of communist organisations. This was the Communist International (usually referred to as Comintern), which was based in Moscow and sought to guide and coordinate communist groups around the world. It was the exact kind of network that could sustain a widespread recruitment effort, with experience in operating relatively clandestinely and in many cases illegally, and fostering connections across borders between individuals and affiliated organisations. Culturally, interwar communism was also a natural home for those who might want to volunteer - these were organisations that actively sought to emulate and follow the Bolshevik revolutionary model, seeking to foster an elite, disciplined and politically united vanguard of the proletariat. Communists' belligerent attitude towards fascism - advocating confrontation and containment both internationally and on the streets - also meant that communist parties were generally home to those who were keenest to take direct, decisive action against fascism.
The Comintern was put in charge of organising this international army, using its national affiliates to recruit volunteers, its transnational connections to get them Spain and its elite operatives as the military and political leadership. Even when France closed its borders with Spain, the Comintern (and the Communist Party of France) were able to set up an effective system to smuggle volunteers south from Paris and across the Pyrenees. Unlike the first wave of volunteers, this new wave would join dedicated international formations that became known as the International Brigades. They never had a complete monopoly over foreigners fighting for the Republic, but the bulk of foreign volunteers (about 90%) ended up in their ranks. This was due in part to their absorbing many of the ad hoc international formations, but also because the Comintern recruitment networks were much better organised, and the number of volunteers rapidly increased over the winter of 1936-7, with smaller but significant flows being sustained through to spring 1938.
Comintern's involvement meant that the volunteers themselves became more homogenous, both politically and socially. George Orwell is actually a good example of how that might happen - he had applied to join the International Brigades in London, but failed to convince the Communist Party of Great Britain that he was politically reliable enough - they weren't massive fans of his recent writing (this was pre-Animal Fram and 1984, the issue was more that they saw Orwell as middle-class dilettante), and figured he just wanted to go to Spain so he could write about it rather than being fully dedicated to the cause. Orwell instead managing to leverage connections with the British Independent Labour Party, which in turn had connections with a small Spanish revolutionary party (the POUM), and Orwell was able to join a small group of non-communist international volunteers serving in their militia (Hemingway, for the record, did not actually fight in Spain, but went there as a journalist).
The result was that the International Brigades were dominated by the Comintern, with national units generally run by their respective national communist parties (the American Abraham Lincoln Battalion, for instance, was dominated by Communist Party of the USA leaders). Not every volunteer from this point onwards was a formal member of a communist party - depending on the national grouping, the figure was usually somewhere between 40-60% - but even those who weren't formal members were those considered politically reliable by the Party (unlike Orwell) and had broadly accepted that the communist policy of confronting fascism was the correct one. While these units were not always politically harmonious in practice, not least because they went through some brutal, disillusioning experiences, they were a far cry from the very varied array of volunteers that first went to Spain. This was a Stalinist army in terms of culture, politics and organisation.
One important caveat to end on here is that it might be tempting to read 'Stalinist' in particular ways here (particularly given the connection with Orwell, who left the conflict as a dedicated anti-Stalinist). It's important to acknowledge though that the Spanish Civil War happened at a key moment of transition for Stalinism - the Great Purge kicked off during the war, and in any case, foreign adherents to communism were generally attracted to an imagined, idealised version of Stalinism and the Soviet Union, who took the pretensions of Soviet democracy under Stalin as real. While there were undoubtedly politically dark sides to the International Brigades - the obsession with Trotskyists and other potential enemies within is very obvious in the source material - for the most part, the foreign communist volunteers were trying to run the International Brigades as they imagined their idealised Bolsheviks might, rather than trying to emulate the reality of Stalin's rule.
(while I've touched indirectly on some of the reasons why Spain saw such an unprecedentedly large number of volunteers, if you're after a more specific treatment of the question, I answered it in quite a bit of depth here).
/u/crrpit knows a lot about this topic and has previously answered:
/u/Georgy_K_Zhukov has previously answered a similar question about the Abraham Lincoln Brigade during an AMA. See also Did Americans fight for the Nationalists in the Spanish Civil War?