What is the best way to teach children how to go under the water without getting water up their nose?

Depending on the age of the child I would generally start by lifting them slightly and going into the water forehead first and then goggles first. practice holding their breath for 6 seconds then breathing out.

For an older child complaining that the water goes up their nose when doing freestyle this will happen as they role out for a breath and it is due to in correct technique. The head and arm need to be together when they role out and you want to be able to see that their mouth is on the same plane as their eyes AS they roll out. In other words you could draw a level line from forehead to chin.

Nose plugs are probably a bad idea because they don't teach your child how to adapt to the water but how to overcome it. Also promotes incorrect technique. Once the nose plug is gone, in goes the water because the child hasn't learned what to do. Same goes for inflatables that parents like to have their children wear; you can't learn to be a strong swimmer by floating.

blowing bubbles through your nose and humming a song usually does the trick!