How do you polymorph? What is the command or key I must use?
You can't really polymorph at will.
There are 6 different types of things that can polymorph you.
Stepping on a polymorph trap will turn you into a random monster (magic-resistance will block this)
The spell of polymorph, cast at you (at yourself or possibly by a monster, though I don't think they cast that spell)
Wand of polymorph, zapped at you. Monsters can't do this, but you can also zap yourself.
Wearing the ring of polymorph (not polymorph control) will cause you to polymorph at random intervals and into random monsters (beware, you can just as easily turn into a dragon as a lichen).
Drinking (and maybe thrown at you) a polymorph potion.
Eating a chameleon or doppelganger (both natural shape-shifters) corpse. Note the doppelganger corpse counts as cannibalism for humans.
Becoming a werecreature, either wererat, werewolf, or werejackal, will randomly polymorph you into your animal/human form. Praying, eating wolfsbane, or quaffing holy water will fix you however.
In wizard mode, the extended command
Note if you are already polymorphed into a magic-resistant monster (most common is grey dragon), some of these methods won't polymorph you.
For more information about the effects of polymorphing, see the Nethack wiki page on polymorph.
All forms of polymorph other than being a werecreature and
#polyself in wizard mode don't let you control what you turn into.
In addition, ring of polymorph and being a werecreature don't let you control when you polymorph. Eating a shapeshifter corpse, being cast at/zapped, and drinking polymorph potions apply immediately, and only polymorph you once.
While a werecreature, you can only polymorph to and from your wereform and normal form.
Finally, with a ring of polymorph control you can always control the result of a polymorph, including not changing at all. This will also stop transforming into/from your wereform if applicable, but will not stop you from gaining lycanthropy in the first place.
Doppelganger corpses will polymorph you, as well. And, if you happen to be a lycan (werecreature), you will polymorph into that particular creature at random (often, inconveniently or worse) or you can quaff unholy water to change at will. Regardless of how you polymorph, changing back still takes an unspecified amount of time between 500 and 1500 turns of the time counter or dying in monster form. As a lycan, you might be able to pray out or eat wolfsbane or quaff holy water (all of which "cure" you of the affliction). Be sure to summon some pets before curing yourself, you may get a pack of winter wolves orbe able to poly your pack of rats/jackals into something really formidable later.