Charles C. Lynch seemed to be doing everything right when he opened a medical marijuana dispensary in the tidy coastal town of Morro Bay, Calif. The mayor, the city attorney and leaders of the local Chamber of Commerce all came for the ribbon-cutting in 2006. The conditions for his business license, including a ban on customers younger than 18 and compliance with California’s medical marijuana laws, were posted on the wall. But two years later, Mr. Lynch was convicted of multiple felonies under federal law for selling marijuana. He is one of hundreds of defendants and prisoners caught in the...