They have light outside the walls. They also have infantry support and potentially archers, and positions where they can hold the enemy rather than charging aimlessly at them with no hope of actually achieving anything.
What, more fecked than dead in about 20 seconds because they charged without knowing what they were doing and with nobody nearby to help them? Look at how much better the packed infantry fighting from defensive positions fared. The dothraki would have been more use in a support role on foot behind the unsullied, cutting apart anybody who gets through the gaps, helping to fight in hand to hand combat on the walls etc. That's 40 thousand more men helping to stop the dead breaching the walls.
Instead that 40k was thrown away for no reason, blindly. I don't get how you can possibly justify that as a sound tactical decision. The dothraki are superb individual warriors, either on horseback or on foot. In this situation the horses were not needed since it was a battle with no visibility in front of a defensive position. Dismount and keep them within the castle, it's not really that hard.
It is lazy. A competent commander does not make that decision, especially commanders who have great experience with the enemy they are fighting and how dangerous they are. There's a reason they didn't decide to march on the NK and fight him in the open field.