Rav Huna had a lot to answer for. His lectures went on, and on, and on, and on and on and on. A couple of pages prior, on Yevamot 62b, Rashi explained the relationship between these lengthy classes and infertility:
שהיה מאריך בדרשיו וצריכים למי רגלים ומעמידים עצמן ונעקרים
[Rav Huna] would speak for a very long time and those present would need to urinate but would have to prevent themselves from doing so...
The suggestion here is that holding-it-in can lead to problems of fertility. and there is a least a theoretical reason why Rav Huna's lengthy classes had the unintended consequence of lowering the reproductive rates of his students. There is a clear relationship between male infertility and repeated infections of the genito-urinalry tract. Here, for example, is how one urology textbook opens its chapter on male genital tract infections and infertility:
Any male GU infection such as prostatitis, urethritis or epididymo-orthitis can reduce both sperm count and the quality of the seminal fluid. OK, but what does that have to do with not urinating when you feel the urge? Well here's the thing: that not-going-when-you-need-to is not a good idea.
It's quite a challenge to determine scientifically the effect of holding-it-in (and hereafter referred to as delayed micturition, beause it sounds nicer) on the risk of getting a urinary tract infection. You can't very easily randomly assign one large group of healthy volunteers to urinating whenever they want, and a second to urinating only three times a day. (I, for one would not readily volunteer for such a study.)
However, there are a couple of observational studies that may be able to tell us something about the risk of delayed micturition. A 1968 study of 112 women with a documented UTI reported that further UTIs could be reduced by voiding every two hours during the day (which sounds rather too good to be true). And a 1979 study from the (not-very-widely-read-but-it-really-is-a-journal) Scandinavian Journal of Urology and Nephrology reported that the frequency of UTI was significantly higher among women with three or less voidings per day compared with those who have to go four or more times per day. (Whether this is true for women outside of northern Jutland where the study was conducted remains unclear.)
So a decreased voiding frequency is associated with an increased number of infections, and urinary tract infections are associated with decreased fertility. Thus by the rule of transitive relations (or something clever like it) decreased voiding may indeed be associated in a causative way with decreased fertility.
All this is highly speculative, and it would certainly be unusual for male sterility to directly result from delayed micturition. But here's the weird thing: teachers are slightly more likely to suffer urinary tract infections when compared with the general population. Is that because they too, like their students, hold-it-in? (Yes, I know it didn't reach statistical significance, but the authors thought it was important to note, and so do I.)
Poor Rav Huna, talking on and on and on, while his miserable students had to sit there with their legs crossed and could likely only think of only one thing. We will give the last word to Rav Acha bar Yaakov, another hapless student of Rav Huna.
אמר רב אחא בר יעקב שיתין סבי הוינא וכולהו איעקור מפרקיה דרב הונא לבר מאנא
Rav Acha bar Yaakov said, we were a group of sixty students, and all of us became sterile because of Rav Huna's lectures - except me (Yevamot 64b).
Students be warned.