One who accidentally eats or drinks on a fast day must continue fasting, because these days were instituted as fast days due to the troubles that occurred on them. Even if one eats or drinks enough to be considered as one who broke his fast, thus forfeiting the ability to say Aneinu in Shemoneh Esrei (as we will explain in halakha 9, below), he is still forbidden to eat or drink. After all, one who committed one sin is not allowed to commit a second (SA 568:1). In such a scenario, the person does not have to fast a different day to make up for the fast he broke, because we are obligated to fast specifically on the days that our Sages established for fasting. Indeed, some people have a custom to accept upon themselves another fast to atone for the one that they broke, but one is not obligated to do so (MB 568:8). It is better to atone for this by giving more charity and learning more Torah.
The poskim debate the halakha of one who forgets that it is a fast day, makes a blessing over a cup of water, and then remembers the fast. Some say that the prohibition of making a blessing in vain is of Biblical origin, while drinking on a fast day is only a Rabbinic injunction. Therefore, it is preferable to take a small drink in order to save oneself from saying a blessing in vain. Others maintain that since most Rishonim hold that a blessing in vain is a Rabbinic prohibition, it is better not to drink at all. In addition, it is improper to fix one sin by committing another one. It seems [to me] that this is the course of action one should take.