I've read that Switzerland stayed out of the UN because of "neutrality". Can somebody elaborate on this? What did it do with other pre-UN organizations?
Also, if it's not a too recent question, why did it back out of this decision in 2002, even if by a small margin?
Historically the Swiss notion of "neutrality" has evolved quite a bit.
First it is important to note that the Swiss practice direct democracy, so such matters are decided in referendum. To quote its 1848 law: “the federal constitution grants the people ultimate power when making and legitimising foreign policy."
At the end of WW1 the Swiss joined the League of Nations in a referendum not because it was viewed as a compatible meeting of collective security and neutrality, but because of how the choice was cast. A lot of work was put into demarcating the meaning of neutrality, in particular to differentiate between "neutrality policy" and "the law of neutrality". The latter is applicable in case of war, the former in times of peace. Thus the Swiss could participate in economic sanctions along with members of the League as long as it is militarily neutral. This is called "differential neutrality".
The 1920 referendum passed with 56.3% voting yes.
This differential neutrality did cause some complications, for example Entente troops weren't allowed to cross Swiss territory even under League sponsorship. However the Swiss were never challenged with sanctions.
Over the first part of the 20th century the Swiss moved further into a trading economy, away from its formerly agrarian economy. So there was more pressure to trading and maintaining trading ties especially with neighboring countries. As a result, when Italy invaded Ethiopia in 1935, the Swiss insisted not only on military neutrality but also economic neutrality, or in essence refusing to join in the League's economic sanction against Italy. The Swiss federal council asserts that as a sovereign country, it cannot be forced to comply. Several other members of the League followed suit and thus the concept of differential neutrality fell apart.
In 1938 when Germany annexed Austria, the same theme was played with the Swiss declaring they cannot comply with any economic sanction, and even further that the distinction between military and economic neutrality is null. Basically they backed out of their previous position in 1918-1920.
Given the failure of the League with the outbreak of WW2, the UN was set up under a different premise, and that neutrality was dead. The allies put pressure on Switzerland's failure to declare war on Nazi Germany and requested the Swiss surrender German assets in Switzerland. Thus, in the early years of the UN the Swiss had no place in the organization. It's only later that the UN started to become more universal, with more recently independent countries wishing to join. With increasing membership, the UN's role around the world increased, and the Swiss became more involved even though they aren't formally a member.
Keep in mind though that to seek membership in the UN will require a referendum, and thus what is foreign policy becomes domestic policy. It took many decades for support of economic integration to emerge, and with it the realization that the Swiss cannot endure its political isolation due to non-membership. That's why only in 1986 was there finally sufficient political will to hold a referendum. This ultimately failed because due to lack of debate, and thus votes were run along the party line, and the anti-UN party won.
In 2002 things had changed considerably. The Cold War was over. However, the Balkan crises created a refuge crisis that affected the Swiss quite a bit. Thus, the argument that isolation gives safety is now moot, even from a right-wing perspective. More strongly, the Swiss now consented even to sending Swiss troops under UN command, something they rejected even just a decade prior.
So basically to understand the Swiss and the UN, it is important to understand how both of them have evolved over time, and how the world around them has, too.