The one thing to note about D&D is that you won't always be in a Dungeon and you won't always encounter Dragons. More often than not you are role-playing your day away while bartering with shopkeeps or asking a King if they can raise the pay in that quest you're looking to take on.
Everything in moderation of course but when you do finally meet the Dungeon or the Dragon it is a rather special moment. It's special for both the players and the Dungeon Master, while dungeons can definitely bring in a very nice break from the expansive outside world a Dragon can bring devastation and death.
As a Dungeon Master, the layout of the dungeon is just as important as what's in the dungeon. Working out the layout to make it interesting and non-repetitive can be a difficult task and you also have to remember that your dungeon needs to be populated. Depending on what type of dungeon you are putting your players in there are a few key things you need to remember.
Traps are your friends but be careful of how deadly the traps are since you can easily kill an entire inexperienced party. As a DM you have to very conscious of the types of traps and monsters you put in a dungeon. You also have to keep in mind the level of your party. You wouldn't throw a Beholder at a level one party, at least not without some heavy modding.
Make the dungeon's surroundings interactable. This means there are spots in the dungeon that can be accessed via a special combination of locks of moves the players make. It could also mean that in certain areas where a battle takes place there are things the players can interact with that could potentially turn the encounter in their favor, or hinder them. Puzzles can be a big break in the monotony that can happen in larger dungeons and adds a very nice change of pace that offers plenty of chances to role-play for your players.
Make the boss fight interesting and more than a hit-and-miss game. Adding in some flavor to the boss fights can really make the final dungeon encounter more memorable. There are several ways that this can be done in a TTRPG, one way to do this is to add a chase scene where the players have to either chase the boss or be chased by the boss at some point in the battle (Check out this Chase article by Hipsters & Dragons for a better chase sequence). This helps to change the pace at some point in the fight that way the players have a change in the type of combat. Also having interactive surroundings for both the players and the dungeon boss can make for an interesting and fun battle. The dungeon boss would have a bit of an advantage since they know the dungeon better but the players would be able to perceive their surroundings and gain the upper hand. It all comes down to how you want to run that final encounter really. The power is literally in your hands.
Always reward the players with something extravagant. Make sure you reward your players with something awesome after that cruel dungeon crawl and that grueling boss battle. You can reward them with magic items or with a hoard of gold that would make a dice goblin proud! Just be sure that the pot of gold at the end of the rainbow was worth the journey they made to get there.
All in all, running a dungeon can be done in so many ways. While you may not have to incorporate all of these tips into every dungeon as long as your players have fun you've done your job as a DM. Best of luck running your next dungeon run and remember to have fun!