81a Tosfos s.v. Sakva. Tosfos says because of Avin or Abaye's statement here (depends on the girsa), we have a custom to fast on a Monday, Thursday and Monday (hence BeHaB - yom bet, yom heh and yom bet) after Pesach and Sukkos - for atonement for the mingling of the sexes during yom tov. This is also brought by Rosh (Taanis Perek 1 Siman 20) but for a slightly different reason: perhaps with all of the feating we sinned, as we find Iyov brought sacrifices after his feasts because maybe his children sinned (Iyov 1:5). Sefardim do not have a custom of Behab.
Rambam (Yom Tov 6:21) says that Beis Din must set up guards to keep a lookout in all places where men and women may congregate to make sure people don't gather there and come to do aveiros. Maggid Mishna says our Gemara is the source for the din of the Rambam. It could be that the Rambam learned this gemara as an a priori law - this is likely to happen, so prevent it. The Tosfos and Rosh may have understood it as a post-facto statement - because these things happen, they promoted making fasts as forgiveness.
It is interesting that the Tur mentions the fast of Behab in O"C 492, and the Rambam's law in O"C 529, with the laws of celebrating Yom Tov. That would indicate that the Tur felt that Behab and the Rambam's law are different. Aruch Hashulchan mentions our Gemara in both places, but adds in 529 that Beis Din only has the responsibility of appointing guards in the time of the Beis Hamikdash. (Mishna Brura ignores our Gemara and only mentions the reason of the Rosh.)
Why does the Aruch Hashulchan limit it to beis din bizman habayis? I have two possibilities. The first is that he understood the Rambam as dealing with a real beis din appointing guards, and we no longer have real batei din. For example, see Rosh Hashana 29b that Rabi Yochanan ben Zakai decreed that if Rosh Hashana fell on Shabbos, we only blow shofar where there is a beis din - it is a beis din of semuchim, etc. (see Rambam Shofar 2:8-9. [That Rambam is a proof to what Chiddushei Hagram says in Hilchos Kiddush Hachodesh about Beis Din Hagadol after they left the Lishkas Hagazis.] The Rif argues with Rambam's formulation; he had them blow shofar in his place because he paskened he had a beis din kvu'a. See Tur 588 from Rosh, Rosh Hashana 4:1.) So maybe Aruch Hashulchan understood the Rambam's use of the term Beis Din here in Hil. Yom Tov like they are used in Hil. Shofar. The second possibility is that the Aruch Hashulchan understood Tosfos and the Rambam as dealing with gatherings for the regel when people made aliya leregel to Yerushalayim. Careful readings of Tosfos and Rambam yield no allusion to aliya leregel, but maybe that's how Aruch Hashulchan understood the halacha.
For more details about Behab, when we keep them (not until the month after yom tov) and why that is so, see Encyclopedia Talmudis volume 2 under "Behab."