In order to access certain dungeons, you need to be carrying a certain HM or have a teammate that knows that HM. You can't teach a Pokémon an HM move in a dungeon, only in a friend area. The HM will not be used up; you can use it however many times you need to. This guide will tell you which HMs are needed where, and where they can be found.
Needed to enter: Stormy Sea, Silver Trench, Grand Sea
This HM is given to you by Whiscash in Whiscash Pond after you talk to Medicham and Lombre in Pokémon Square. If you lose this one, you can find another in Solar Cave 10F. You need a key.
Needed to enter: Sky Tower (after first time)
Fly is found at Wyvern Hill, the 30th floor. You need a key.
Needed to enter: Fiery Field, Lightning Field, Northwind Field, Mt. Faraway, Western Cave, Wish Cave, Far-Off Sea
Surf is found in Solar Cave, 20th floor. Here, you need to have either a Water Pokémon or one that can float above water, because the HM is surrounded by a ring of water.
Needed to enter: Waterfall Pond
The Waterfall HM is located on the 15th floor of Solar Cave. You need a key.
There are four other HMs: Cut, Flash, Strength, and Rock Smash. These HMs aren't necessary to access certain dungeons, so you'll never really need them during the game. But they can be used multiple times like any other HM.