For many Americans, buying fresh local food at one of the estimated 9,000 farmers markets across the U.S. is one of summer’s pleasures. But farmers markets aren’t just nice amenities. Over the past 18 months, many have filled food supply gaps caused by COVID-19 shutdowns.

While...