Credit card companies may view payments directly to a state lottery as being different than other forms of gambling, and/or they might not have a clue what the payment is for depending on whether they payee is "State lottery" or "State treasury" or something else. That's why you can sometimes use a credit card to buy lottery tickets at a retailer. Typically the credit card company will only know how much the charge is and who the payee is, so to them it's no different than paying for anything else sold by the retailer. The law or the store's rules may prohibit paying with a credit card, but I normally don't expect anything to prevent paying with a credit card except for the clerk following whatever rules might be in place.
FWIW, I recently discovered that sometimes the credit card company might actually know something about what you're buying. I was out of state and wanted to buy a multi-draw ticket but I was low on cash and my ATM card didn't work for some reason. I was in a chain store so I bought one of their gift cards, figuring that should be a suitable work around. I paid for the lottery ticket by putting the gift card in the same card reader I'd used the credit in while buying the gift card, and the receipt specified that the charge was for the lottery. I don't know for sure that paying directly with the credit card would have also shown that the purchase was for the lottery (or if a credit card charge wouldn't have gone through), but until then I wouldn't have expected the card reader to know what I was buying under any circumstances.