This is actually just enrichment for them. Kind of like a cat knows that they won't catch a laser pointer if they chase it, they just want to exercise their natural hunting instinct.
The cat actually doesn't know and if that's the only form of enrichment they can get incredibly stressed out because they are never able to catch anything, so people should give their cats something real to chase after using a laser pointer.