Why does Slotted Aloha work?

So the way I understand it, if station A and station B, for example, try to transmit a frame at the same slot, a collision occurs, leading to an attempt at the next slot. But wouldn’t the algorithm just repeat itself? The same two stations would try again on the second slot and it would still cause a collision. Also, it means that the first slot would remain unused.

Am I understanding it wrong?