Not if the money is earmarked - you're making an unstated assumption that, say, if 5M is going into education, and a lottery starts up and brings in 5M more for a total of 10M, that the original 5M must be repurposed elsewhere.
That's not necessarily true in the first place, and what's more it depends on the appropriations rules in the jurisdiction.
I'm making that assumption because I saw exactly that happen in New York. The lottery money is earmarked, sure, but it simply replaces money that otherwise would have been allocated from the general fund. You could just as well earmark the lottery money for sanitation, cut the sanitation budget, and then put the money towards schools or other uses.
That's not necessarily true in the first place, and what's more it depends on the appropriations rules in the jurisdiction.