Many players believe that the spinning reels on the screen are "calculating" a result as they slow down. In reality, the outcome of your spin is decided the very instant you press the spin button. The animation you see is simply a visual presentation of a result that already exists in the game's memory.
This is made possible by the Random Number Generator (RNG). The RNG is a sophisticated algorithm that generates thousands of numbers every second, even when no one is playing. When you click spin, the game picks the current number from the sequence and maps it to a specific combination of symbols on the reels. Because of this, every single spin is a mathematically independent event. This means a game does not "know" if you have won or lost ten times in a row; the odds of the next spin are exactly the same as they were on the first.