Trenches (fighting holes, slit trenches, etc) were indeed used in World War II by all major combatants. Their main purpose is to provide fighting cover for troops on the front line from enemy fire, and to fight without providing your troops the ability to gain some kind of cover will quickly diminish your forces.
The stark difference between their use in WWI and WWII was that trenches typically did not become static front-lines for long periods of time (lasting more than six months). For example, during the period known as the "Phony War" (October '39 through April '40) , the British and French armies prepared fighting positions (trenches being among them) along the projected front lines along with permanent defensive positions (the Maginot Line for example) to prepare for an eventual confrontation with German Forces.
These positions were either quickly overrun, flanked, or abandoned during the German offensive in the Spring of 1940. The tactics of the last war were quickly outdated thanks in part due to combined arms and blitzkrieg tactics employed by the Germans during this offensive. Ironic in part as well, as the Germans did not learn from this lesson either when later constructing the Siegfried Line or the Atlantic Wall.
Despite this, trench networks, foxholes, etc, were still used by all major parties throughout the rest of the war, the difference though was that they were usually used to consolidate gains made during the war (and to provide a jumping off point for whenever a new offensive was to take place, Kursk for example) by their forces, rather than being used as a sole, static line of defense.