It’s magnets! Seriously. There’s a layer of iron underneath the cue ball that gets nudged and pulled by a strong magnet inside the pool table so that it gets put on a different track from the rest of the balls in pool.
The other balls in pool don’t have metal inside so they don’t react to the magnet at all and just get sent down to their regular station. This is true of many pool tables, while you will also sometimes find tables where there the cue ball is slightly smaller in diameter than the other balls on the table, and is therefore caught along a different track and sent away from the rest that way.