Every slot machine has its own specific payout percentage. This percentage is programmed into the machine's software at the factory. While it is possible for the casino to change the payout percentage, it is not a simple process so it is not done often.
The payout percentage tells the percentage of all bets that are ultimately returned to players as winnings. However, the actual play of each pull is determined by the Random Number Generator (RNG). So one player can play for two hours at a machine and lose and the next player can win a substantial amount with their first play!
The payout percentage is based on the lifetime of the machine. Because the RNG determines the result of each individual play, the payout percentage can be, and often is, realized fully in a relatively small number of high-paying wins stretched out over the lifetime of the machine. All other winning combinations over the lifetime of the machine will be relatively small. This doesn't mean that you can't win. Of course you can! But you must understand that most winning players win small.
All states that allow casino gambling set a minimum payout percentage for slots. Most casinos have a payout percentage much higher than the legal minimum. At land-based casinos, where overhead is higher than online, and the number of slot machines is limited by the casino's size, the payout percentage is usually around 85%. Online the percentages are from 95% to 98%. Even when the house keeps only 2% of monies wagered they make a neat profit.