German stupidity in WWII barely possible, in WWI no way. Invading Switzerland gives Germany nothing, crossing part of Switzerland to attack over the French/Swiss border is not going to be useful - tough terrain and not a good infrastructure going this way to support such an attack. The Swiss certainly aren't going to do anything, they are completely surrounded by combatants so joining one side opens you up to attack by the other. Neutrality allows the Swiss to access imports, and export to all sides for a tidy profit.
In a Germany wins scenario of WWII I still don't see Switzerland being invaded - certainly the Swiss would be very much in the Nazi orbit, but those Swiss banks and also Swiss neutrality as a conduit to those outside of the Nazi sphere are too good to spoil by actually taking over the country.
Whether WWI or WWII Switzerland joining the war on either side gets nothing for them, and anyone invading in either war is a waste of resources that gains little if anything. I can imagine if threatened the Swiss quietly tell their potential enemy that all data on bank accounts from their country will be made public, and the accounts confiscated...ouch!