For cross country skiing there are two kinds of wax that serve two purposes: one to glide and one to grip. skate and classic techniques both need glide wax, while only the classic technique needs grip wax. Basically, in order to glide a ski will melt a thin film of water between the base of the ski and the snow as lubrication. If this film is too thick then capillary action will produce a sort of suction effect, and if it's too thin then there's no real lubrication. The different glide waxes have different properties that produce this perfect amount of friction in different snow conditions. Usually a harder was is used when the snow is colder, drier, or older, and a softer wax is used when the snow is wetter, fresh, or in warm air conditions.
I'm not as sure about the grip wax, but it needs to grip the snow when the skier "kicks" their ski to propel them forward. The skis have a camber that normally raises the mid section above the snow, and when the skier kicks this section is pressed down into the snow. The grip wax is applied here. There's another perfect goldilocks zone with grip wax and snow conditions, where either the wax will stick too much and you're dragging your skis, or it won't stick enough and you can't kick.
No idea about regulations for waxing. Usually, especially at the olympics, each team has a team of wax technicians that test out different wax combinations to find which works best, and do all the waxing for the team.Some links with