I worked for a casino for almost ten years. As much as it seems, they do not decide when someone will win on a slot machine. What they DO decide, however, is what percentage a machine will pay back. Most states that allow gambling legally need the machine to pay back 85%. A rate like that will seem very "tight". Most will be set in the low to mid 90's. That means that if it's set for 90%, then for every dollar that goes in, ninety cents will be returned. That's why you see the small payouts and eventually the big jackpots. This is also how/why the casinos will put better paying machines on the ends of rows and places where more people will see more people winning. If more people see it, more people will spend more money. Look at the traffic patterns. More people generally mean better paying machines.
I have seen back-to-back jackpots on machines. Not kidding. I've also seen machines go several years without hitting jackpots.
There is no need to program them. The odds are already very heavily in the government favor. And even though most, if not all, of the money that goes in is paid back out, the lotto agency pays it out over long time, and they get the interest on that money. Even a small amount of interest is a lot when you're looking at millions of dollars. People who take a cash option give up a lot of that money, so that's one more way for the lotto agency to keep money.
Long story short, there are groups that watch both of these groups very closely. With the lotto, the numbers work so well that there's no reason to cheat. With the casino's, there are many laws and groups that watch very closely. The casino's are fined VERY heavily for any kind of cheating.