During your training you should know when your body needs nutrition and liquids.
Especially for longer workouts (more than 1.5 hours) you should not forget to eat and drink. Also during a race it’s essential to feed your body with new energy at the right moment.
How much should I drink?
It depends on many factors (intensity, temperature, etc.). If you do triathlon, don’t forget that you should drink more on your bike because it’s easier than during running. In general you should drink as much as you lose.