It's an extension of a peace through strength philosophy. If you lose your critical sovereign capabilities you become weak and vulnerable. You no longer get to decide who you do and don't "never go to war with".
Yes I understand the reasoning, it's just obviously wrong. This doesn't happen and hasn't happened in hundreds of years. This is not why people get invaded, otherwise Switzerland would have been invaded many times over the last century
That's exactly why Switzerland didn't got invaded in the last century. Every side depended on them for money supply, so they couldn't risk bringing the war to Switzerland. Also it had a track record of staying neutral, so they didn't feared it may pick a side, because it largely made money from selling stuff from both sides.