The FDA rule on this [1] doesn't appear to be quite that strict: it says the ID can be "a photo identification card issued by the State or the Federal Government or a document that is considered acceptable by the seller". It doesn't explicitly say it has to be from the same state as the one in which you are buying the medication, and it leaves the seller some latitude in what to accept.
Possibly some states have more restrictive rules. Or particular sellers might be more leery about what they are willing to accept.
[1] https://www.fda.gov/drugs/information-drug-class/legal-requi...