They couldn't have won the battle straight up, but those Dothraki didn't do much of anything to delay the Army of the Dead. And it resulted in massive losses.AND
Keep in mind that she told Grey Worm that hers was a peaceful people incapable of defending themselves. They choose no violence.
IMHO everyone is missing the boat with the strategy and tactics of the Battle of Winterfell. Everyone bitching about the cavalry charge are forgetting that this is not a set piece battle wherein the living can prevail on the battle field. The battle is just a delaying action by the living trying to hold off the AOD long enough for the Night King to expose himself. Keeping that in mind along with the sheer numbers of the AOD, look at the pieces and tactical choices:
1. Dothraki Riders- There is not going to be an opportunity of a flanking attack so the choices are a bit limited here. do you hold them close to the castle and negate their greatest skills, a charge? Range them out as your first level of defense. Nobody in charge believes that this will be successful as far as defeating the AOD, but it starts the battle away from the castle.
2. Unsullied- set in place to protect the Dothraki retreat, if they survive, and provide the second layer of defense. The vanguard protects the retreat of the Dothraki and most of the Unsullied while the trench is lit. This gives added layers of defense … unsullied, trench then Unsullied/Dothraki again.
3. Trebuchets- Yes, you would like to see them have longer barrages as the AOD approaches but for one we do not know how much shot they were able to produce in the buildup. Building/keeping them in the castle would be counter productive … they take up too much space that can be better used for castle defense.
Keeping in mind that Jon/Dany knows that they cannot defeat the AOD in battle, and that is never disputed by anyone, their only option is to delay long enough for the NK to expose himself. Their strategy was to delay long enough to have the NK … the AOD's only weakness ... expose himself to have a chance to win the war, their tactics matched the strategy.
It would have been an actual delaying strategy to split them into two groups on the flank to hit and run. They would have drawn strength of the army away from the fight against the castle itself. And they would have been a lot safer and more effective outside where they would have had a speed advantage to snipe the edges, rather than a frontal assault on a tidal wave of bodies.