This is one article explaining how this "gray market" operates. Millions of dollars are at stake so some veterinarians are solicited to order mass quantities of the products and then sell the excess products to a broker or some of the very companies who manufacture the products are selling to people who shouldn't have access to them. This article is mainly talking about Frontline but it's the same concept for heartworm products. It's quite an interesting read....
Veterinarian investigates illicit diversion of flea products - VIN