I actually learned that trick in college, while commiserating about having to rewash clothes 2x to get the funk out.
I usually just wash them again with the same soap and they come out fine. Also front loaders are like 100x worse for mildew. My front loader, which was a super modern, brand new machine, everything would stink if you forget your clothes for a few hours. My 30 year old top loader... I gotta leave the clothes in there for about 2 days before it stinks. Forgetting them for a day is never a problem. At least not to my nose...
One theory is that the acid just cancels out hard water and makes the detergent more effective, but I don't buy that. Seattle water is so soft that home brewers have to add minerals to the water or the yeast won't multiply properly. In fact most of us are using way too much detergent in our laundry and our dishwashers because of it. I've also run out of vinegar enough times and have known this trick for enough years that I know for certain that washing 1x with vinegar always gets the mildew smell out, but 1x without it only works less than half the time.