If the debris you hit kicked your front wheel laterally enough so that your center of gravity was not over your wheels, or if the change in your momentum caused your body weight to shift so that your center of gravity was not over your wheels, and if you couldn't correct (i.e. shift your weight or turn you bars) in time to get your wheels back under you, you would go down.
Sometimes a rider can instinctively act to recover from something like this, but it depends on the magnitude of the deviation from center of gravity, where your body weight at that instant is and how quickly you react - it happens far too quickly for cogitation, you have to react instantly/instinctively. That comes from miles/hours of riding in many types of conditions. Also you can improve your form on the bike - being loose and relaxed with a significant portion of your weight supported by your legs instead of planted on your seat and your hands and your grip on the bar firm but not strangling it. This can help you to react more quickly in an emergency situation.
Keeping mentally alert and tracking road and traffic conditions so that you can anticipate problems is the best means of prevention.