The lottery is rigged. Usually half the proceeds go out in prizes. If you bought every ticket you’d lose about 50% of your money. The rest goes into the coffers of the state sponsoring it.
You always have to pay the house. The state takes a bigger skim than Vegas, but if the odds look good to you (and 1 in 18 million isn’t particularly attractive to me) you know what the risk and the maximum payout will be.
But you’ve ignored the fact that you also pay the house to play the stock market. Although the discount brokers don’t skim as much as the old full service brokers used to, they are going to take their cut except in very narrow circumstances.