Many countries did actually declare neutrality during WWII but several of them were not allowed to preserve that status and were occupied. In particular, Lithuania, Estonia and Latvia all declared their neutrality but were occupied by both German and Russian forces on several occasions throughout the war.
By contrast, Switzerland aggressively defended its border and remained neutral throughout the war although it famously still offered banking services to the Nazis and continued to trade with them.
So neutral status was a combination of desire to remain out of the war and the ability to do so. Countries in non-strategic locations like Ireland and Chile were able to do so simply because they chose not to enter the war (although Ireland was bombed several times ostensibly by German accident) while countries like Portugal, Switzerland and Sweden were aggressive in maintaining their neutrality as they were in close proximity to territory held by the Nazis.
Additionally, many nations (chief amongst them the USA) were initially neutral and only entered the war after the attack on Pearl Harbour. These nations included almost all of Central & Southern America.
Also, nations like Czechoslovakia, Austria, Greece, Poland and France, China and the Phillipines were given no choice in neutrality as they were invaded or annexed very early on in the war. Those actions by Germany, Italy and Japan forced more nations into the war as they each attempted to extend their own spheres of control.
To summarise, nations needed both the desire and the ability to maintain neutrality. That combination was quite rare and therefore WWII expanded to include virtually every nation on the planet.
EDIT: My mistake, France did actually declare war on Germany prior to being invaded.