The Swiss adopted the design of the white cross on a red background as the national flag (the design is older and in 1863 it was used for the basis of the Red Cross’s flag) in 1889. The current version consistently appeared over the years.
It was first used by Swiss mercenaries in the Middle Ages. Prior to 1889, each canton (the Swiss version of a state) had its own flag and national flags varied over the years. When modern Switzerland was formed in 1848, they had to come up with a flag. They tried a few different versions and eventually settled on the square because of its military origins.
When neutral Switzerland joined the UN in 2002, it was a big deal for them. It also presented a problem. UN rules require rectangular flags. Thankfully, a loophole was found. New flags are permitted as long as they do not exceed the size of other flags.
- Why Didn’t Hitler Invade Switzerland? (schwingeninswitzerland.wordpress.com)