One of the basic rules when making nedarim is that the prohibition that is being created should be compared to another davar ha-nadur – something else whose prohibition stems from a vow. Thus, the classic neder has a person saying “this food is forbidden to me like a sacrifice.”
Our Gemara teaches that a vow can be made by a person who says “I will not eat meat or drink wine, just like the day that my father died,” or, “…just like the day that Gedaliah ben Ahikam was killed,” or “…just like the day that I saw Jerusalem destroyed.” Shmuel clarifies that this is true if the person took a personal vow not to eat or drink on those particular days.
With regard to fasting on a yahrtzeit we find that the Rema in the Shulḥan Arukh Yoreh De’ah (402:1) rules that it is a mitzva to fast on such a day, and it is clear that this was a common custom in many countries (see the Shulḥan Arukh, Orah Hayyim 668:8). Even though it was not an obligatory fast, nevertheless the tradition was to be even more careful with regard to a yahrtzeit fast than for minor communal fasts (like Ta’anit Ester, for example). In modern times this tradition has become less prevalent, but a person who does accept it upon himself has taken on a vow of sorts and will be obligated to keep it. Similarly, the Shulhan Arukh rules that it is a mitzva to fast on the anniversary of the day that one’s primary teacher (rabbo muvhak) passed away.
The day that Gedaliah ben Ahikam was killed is commemorated as a communal fast on the 3rd day of Tishrei. Still, it is viewed as a davar ha-nadur if a person accepted upon himself to refrain from eating on that day. The Rashba and Ran explain that this is because the communal fast is Rabbinic in origin, while a personal vow can create a Biblical obligation, which is a stronger prohibition.