Combat is one of the two most important parts of Dungeons and Dragons, in fact, in many ways the combat is what the game is built around since the original versions of the game evolved from War Games that were entirely combat-based. But regardless of origins, combat is a huge section of the TTRPG, so getting it right is vital. Sometimes combat can be very straightforward. Sometimes it gets very strange. Because combat has the most specific, fleshed-out rules of the whole system it's easy to slip into thinking that it'll be a breeze every any time you call for initiative rolls. With these tips, it will be.
1. Don't Break Character
There's nothing that reminds a group that they're just huddled around a table more than when an NPC suddenly makes a brilliant leap of insight to know where the party is planning their trap or what their goal is and heads it off with ease. Just because you, the DM, know what you're party is up to does not mean your monsters do, and vice versa. It doesn't mean always sticking to an accent or doing dumb stuff, it just means playing each monster and character true to who they are. Combat and roleplay are different but they should not be separate.
2. Know Your Abilities
The biggest hold up in any combat scenario is looking things up. It will happen. Even when you have a whole stat block or character sheet memorized something will happen and a rule or spell will need to be looked up. But if you have to double check a monster's movement speed every turn, or look up how many d8s Divine Smite is every second combat, things will slow down.
3. Plan Ahead
This one is just as important for players as it is for DMs. Planning when it combat simply means knowing what you're going to do once the initiative order rolls around to you. This is generally easier for a DM than a player because they can hear the party talk and decide what their monsters will do based on player movements. Also monsters, which tend to make up the majority of enemies, are often dumb as a box of bricks. But planning ahead is just, if not more, important for players. If every player takes two minutes to decide what to do, in a standard sized party that would put every round of combat at nearly ten minutes. Plan ahead, and that first two minutes can be used by everyone at the same time.
4. Keep Everyone Engaged
Combat is supposed to be fun. It's still a turn-based RPG, not a modern beat-'em-up video game that you can't look away from, which means the biggest challenge is keeping everyone focused. The reason this is so hard is that there's no fix-all. Some groups love having their actions narrated like a grand novel, every attack explained: "your sword comes down like the hand of god and cleaves through his breastplate before you combat roll backwards coming up on your feet." Some like things to be told short and sweet: "It hits for 12 damage and you move away, okay Reggie you're up next." Sometimes fast turns keeps everyone engaged, sometimes seeing it in their minds eye does. Sometimes it's something else entirely that keeps everyone engaged. And players, don't forget your DM wants to have a fun challenging combat encounter too, so don't be afraid to do unpredictable stuff or make wild assumptions and act on them.
5. Use a Battlemap
It helps with every single part of combat. Not every combat encounter necessitates battlemaps, but if the map is simple do it anyways. It helps both sides plan their moves in advance, it helps the DM keep track of who is alive and who is dead, it lets the players identify with the little figure on the map and stay engaged. Battlemaps need not be fancy dry-erase grids, they can be as easy as a sheet of paper or a Google Sheet. Somewhere to write down the initiative order and put your characters works wonders for keeping people engaged and planning ahead.
Just like every other part of DnD, combat is a test of finding what works for your group. It won't happen the first time, or every time, but if you work to continue the parts that make your best encounters great, and cut down on the elements that make your worst encounters bad, your combat will get better and better. Never lose sight of the point: have fun. If everyone is feeling like an adventurer, slaying beasts and nearly dying in the process, then you're doing a great job.