One-shots have many differences compared to long campaigns. These differences can make for unique challenges but also for unique experiences. The unique constraints often lead to different approaches out of pure necessity, but also new challenges. I can't possibly go over every challenge that could come up, but I hope to go over some of the most important ones. It also let's me put my thoughts down in a coherent way, which is always a plus. You don't realize some things until you try to write them down, after all.
This kind of thing often comes down to person preference. However I find that 4 hours tends to work best for me. It gives a good amount of time to work with, and is still feasible amount of time for guests. Admittedly it gets kind of close to being too long for a lot of people, but that's roughly where you'd want it I think. A length of time as long as possible but still not inconvenient for your players. 2 hours can work too, but it's a very different skill. You need to be extremely precise and prepared for those kinds of situations and may need to push things along at times to keep them moving at the desired pace. Some groups can spent that long in an inn talking about the last adventure so it really is a challenge. However, it can also be a great experience because there is no filler or anything unnecessary. It's the condensed best things you could come up with.
What I Want
Typically when planning a one-shot, there are a few things I want. I want at least one major and iconic role-play situation. It's the kind of thing that right after, days later, perhaps even years later, they will talk about fondly. I also want to include some kind of combat encounter. People typically like their combat encounters so I usually feel that I want to have at least one. This way the decision of what character they chose means something. Otherwise, players who enjoy the combat aspect will tend to feel like I wasted their time forcing them to pick between a barbarian and a fighter.
I also find I get the best results if there is something else happening in the encounter. It could be the whole place collapsing on their heads, it could be someone trying to escape with something important, it could be an attempt to buy time while a baddie opens a portal to hell. It could also be something unique about the combat encounter itself, such as a creature capable of hiding in shadows or fog that uses hit and run tactics. Again, what I found best here is if there is some problem they need to solve. Everything I mentioned previously, put another way, is just a problem I'm presenting the players beyond “kill everyone”.
Pre-generated characters can be a massive boon in these kinds of situations. It can be a lot to ask someone to create a character for a 2 hour session. This is especially true if the person never played a tabletop game before and you want to introduce them. In these cases you could whip one up yourself quickly a head of time after asking your players what kind of character they'd like to play.
It can also be a surprisingly good change to not come up with your own character. It's a great way to break a rut and it's also very safe. If it turns out you don't feel like you have a lot to work with the character you chose, you may never use them at the end of the session anyway. At the best case scenario though, you could find yourself enjoying a very different experience. Of course, a pre-gen character still leaves a lot of room for a player to make the character their own. You are given a starting point but where you take the character is up to you. It's the being pushed out of your comfort zone that can lead to great new experiences, though I must also preface this thought with the admission that it doesn't always work out. However, it can still be that all important seed. Different seeds can grow to different results.
Having this kind of power is also interesting from the perspective of a Dungeon Master. It further lets you have an element of control over the session and can be an opportunity to say something about the world. Limiting abilities and classes does the same, but it's a different mechanism. I would never advocate preventing players from making their own characters when they want to. It pays off massively from the perspective of player engagement. However, if you find yourself in a situation where you need pre-generated characters because your players won't have the time to create a character from scratch before the session, want the challenge or whatever other reason, it's a valid option. Some players don't mind the challenge either. They may in fact welcome a new character they never would've played had they had that control. If you have these players, there is nothing wrong with giving them what they want.
Setup time is a big enough problem in long campaigns. Since we have even less time to work with, having things run like a well oiled machine is even more important. 10 minutes out of 4 hours may not feel like a long time during play to wait, but the number of things you could have done with those 10 minutes is surprising. It's also one of the easiest things to trim down while not drastically changing the adventure itself. Overrunning the time limit is very common.
If you can, have the rooms ready to go if you are using tiles. It always amazes me how much time this ends up saving over the course of a session. For a massive mega dungeon this isn't always possible, especially when using 3D dungeon tiles. However, you probably aren't going to be running a massive mega dungeon in 4 hours. If you can't get all of the rooms ready ahead of time, get as many as you can and have the remaining rooms planned out. With fewer rooms it's easier to remember, and you'd want to have notes ready as well. This goes for more than just the arrangement of tiles. You'll want to have well organized notes ready if you are like me. It speeds things up, helps me immensely, and at such a smaller scale tends to be easily manageable. The less amount of time looking at rules, the better.
The ending is very important for a one-shot. You aren't building to something in the future like you can do in a normal campaign. This is where all the build up throughout the adventure was leading. It's now or never. Now, I'm not saying that you should always give your players exactly what they want. Most of the time you probably should come close, but ironically giving your players exactly what they want may not be what your players want. Making it just slightly different enough to have a bit of a surprise often works well from my experience. It's the idea of giving your players what they want even if it's not the specifics they would have told you. Again though, you'll need to know your players. The ending doesn't necessarily always need to be completely satisfying from a writing and character perspective. It needs to make sense, be shaped by your players through their actions, and bring satisfaction to your players. What would satisfy the player's character and what would satisfy the player do not necessarily align. Some character's players even create characters that they want to be unsatisfied and lead to tragic results.