Is there anything you can do to prevent dehydration?

Oftentimes, yes. Dehydration means "water loss" & often used generically to describe "volume depletion, " which is salt and water loss, and much more common. Avoiding heated environments or excessive diuretics, drinking plenty of non-caffeinated fluids, and eating healthily are important. If recurrent, this could be caused by a medical condition that requires further evaluation.
Drink water. Dehydration is due to a lack of adequate fluid balance in the body from decreased intake or excessive loss of fluid such as occurs with vomiting or diarrhea. High temperatures in the environment or fevers can cause a net loss of fluid that can be difficult to realize at the time. Iv fluids are frequently required to replace fluid quickly.
See below. Dehydration can be due to loss of fluids from diarrhoe, or vomiting, in which case you need specific treatment for the cause. If due to diuretics which are given for kidney and heart problems, call your doctor and stop them.If you can drink fluids check with your doctor and go ahead or you made need intravenous fluids if you cannot eat or drink.