This advertising presumably motivates citizens who would not ordinarily buy tickets, to buy tickets.
They are not forcing you, of course, but they certainly are encouraging you.
You are not obligated by law to buy lottery tickets, therefore, it cannot, by any stretch of the imagination, be called a tax. Period. They can advertise all they want. You can still say "no".
In fact, you can stand in front of a government lottery official, extend your arm out, point a finger at them and laugh out hysterically while loudly proclaiming that you will not buy their tickets. Try telling the IRS that you will not pay taxes because, well, you don't want to.
I was just responding to your statement:
"No government agency was involved in making you spend the money."
and I was careful to make the distinction between "encouraging" and "forcing" people to spend.
I would rather the government get out of the lottery business, because it seems like a basically useless activity. If we need money, let's ask for money. But it's not a high priority for me. Living in CA, there are plenty of other, much bigger problems than lotto.
One could argue that spending money on a lottery ticket is actually better for you than spending the same amount of money on a soft drink. One gives you hope and entertainment and might have other positive "feel good" side-effects. The other fills you with sugar (high fructose corn syrup) and is not good for anything at all.