It seems weird that Italy would go after Austria but not Switzerland, especially since Switzerland was so much weaker than Austria.
The same goes for Germany. They were trying to unite all germanic peoples, so why not Switzerland?
The Swiss didn't particularly want to join Italy, and that's what made the difference, even if the Italians had a vague desire to annex Canton Ticino.
Italian unification was a pretty scrappy affair. Italian-speaking territories like Nizza and Savoy were unscrupulously traded to France for military assistance (and the existence of Corsica, whose natives speak an Italian dialect, was pleasantly ignored). The possibility to annex Dalmatia after WWI (which was historically Italian) was passed over to annex Süd Tirol in order to guarantee a natural border with Austria, ignoring the fact that the entire area is German-speaking.
While there was a national conversation about the notable exclusions of Italian unification almost immediately after the proclamation of the Kingdom of Italy, the conversation was (similarly to the Italian unification process) spurred by external actors, many in the form of Pro-Italian-Unity political groups, mostly in Austria-Hungary, working towards the diplomatic annexation of ethnically Italian territories like Trentino and Istria.
Apart from the ineffectiveness these groups (the most successful one was able to keep Italy from losing Trieste after World War II, hardly a victory, seeing as the rest of Istria was lost, with a brutal displacement of the native Italian population to boot) they were less vocal and widespread in the Canton Ticino, because before, during, and after the Italian unification process, the Ticinese liberals won several spectacular electoral victories. The liberals, apart from supporting secularization of society, favored public education as opposed to the traditional parochial school system, and were naturally sympathetic to Italian unification, eliminating the need of political activist groups to further the cause in Ticino.
During the Risorgimento, the Austrians very effectively sealed off the border between Austria-controlled Lombardy and Ticino, as several pesky Lombard Risorgimentisti had sought refuge there. This limited contact between Ticinese liberals and the wider Italian Risorgimento.
Another big factor is that in 1845 Swizerland fought a Civil War (called the Sonderbund), broadly against Protestant-Liberal / Catholic-Conservative lines.The Protestant-Liberals, many of whom were Swiss-Germans, fighting for a more centralized Swiss state. The mostly Liberal Ticinese Ruling class, although ruling a devoutly Catholic Canton, naturally sided with the Liberals. Thus, by the time Peidmont had kicked the Austrian Empire out of Italy, Swizerland had adopted a new constitution, centralizing lots of power in the Federal Govornment. Subsequent policies by the Ticinese Liberals to keep the Conservatives out of power following the Sonderbund saw them not only step up their policies of secularization, but asked for the detachment of the Ticinese parishes from the bishop of Como (creating a Bishop in Lugano to which Ticenese pastors would report) leading the Canton to be further distanced from Italy, which in spite of a strong liberal current among its intellectual class, came out of the Risorgimento as a very conservative and reactionary state.
Further, all these considerations existed almost solely for the intellectual/ruling class. Part of why the Ticinese Liberals were so focused on consolidating power inward (setting aside their pro-unification sympathies) was that they were ruling a fundamentally conservative Canton, whose population was by and large illiterate, staunchly catholic, employed in agriculture, and possibly only vaguely aware of the Italian unification process.
It didn't "go for Austria". Austria was holding many territories that were ethnically Italian, that was the reason for the conflict, and at the same time it explains why they didn't go for Switzerland.