Federal laws prohibit false, deceptive, unfair etc. advertising, and there simply exists no federal law prohibiting advertising marijuana. Because of the First Amendment, there is no law prohibiting the advocacy of an illegal act. Because of the Commerce Clause, Congress could pass laws restricting commercial speech, as long as it passes strict scrutiny, see Central Hudson Gas & Electric v Public Service Commission of New York. However, "For commercial speech to come within the First Amendment, it at least must concern lawful activity and not be misleading". So Congress could pass a federal advertising ban. A state where marijuana is illegal can do likewise, but as you noted Twitter does not cross that line. Washington allows marijuana sales and advertising, however "A cannabis licensee may not engage in advertising or marketing that specifically targets persons residing out of the state of Washington" (not even Oregon where the herb is also legal). Still, the state attempted to limit advertising which resulted in Plausible Products, LLC d/b/a Hashtag Cannabis v Washington State Liquor and Cannabis Board. The ruling observes that
The State argues that, “[f]or purposes of the first Central Hudson
test, marijuana activity cannot be considered to be ‘lawful activity”
where its use, possession, manufacture, and distribution remains
illegal under federal criminal law.”
§2(B) analyses this rationale, quoting from New England
Accessories Trade Ass’n v. City of Nashua, 679 F.2d 1, where the New England
Accessories court also considers that
“If New York, or some
other state, decided to legalize the sale and use of marijuana, New Hampshire would have
greater difficulty . . . prohibiting an advertisement suggesting that the Big Apple was the
place to get high on marijuana.” The Plausible Products court then concluded
It follows that, where one state could not avoid Central Hudson
scrutiny for banning advertisement of Washington recreational
marijuana, neither can the State here avoid Central Hudson scrutiny on
the basis that recreational marijuana is still illegal under federal
law
There are other relevant tests applicable to restrictions on commercial speech –
is the government's interest substantial, does the regulation directly advance that interest, and is it narrowly tailored. Presumably, the state interest would be in preventing underage consumption (accepted by the court). Another possible interest, rejected by the court, was "not tipping off the feds", with reference to the "federal government’s expectation of a strong and effective marijuana regulatory system". But as the court noted, the Cole Memorandum was rescinded, and states cannot rely on it, thus the "asserted interest in avoiding federal
intervention is too elusive to amount to a substantial interest under Central Hudson".
The Twitter restrictions on cannabis ads are very similar to the Washington state regulations on such advertising. Allowed ads seem to be reined in to meet the general state interest (in restricting underage consumption), so I conclude that there are no legal consequences of their business decision.