This is a classic magic trick! And it demonstrates one of the most important aspects of many magic tricks. If you have not seen this page (or one of the many like it), go try it and see how it works. Unless you catch what is happening, it is amazing the first time you see it! Do not read the explanation until you have tried the trick yourself.
This trick, like many magic tricks, relies on the power of suggestion and the fact that the human brain does not tend to notice fine detail. You can start to get a sense of what is happening by repeating the trick, but this time picking two or three cards instead of just one. Try it one more time and write down all of the cards that appear in the first deck, and then all of the cards that appear at the end, and you will see exactly what is happening. All of the cards have changed!
When most people try this trick, they look at the first deck and the brain registers a general fact like, "a collection of cards." The brain does not store the actual face of each card. So when the second deck is shown, the brain again registers "a collection of cards." The fact that all of the cards are different escapes notice -- it is assumed that they are the same because none of the detail was stored.
This same phenomenon allows a magician to saw a person in half. When the person is placed in the box, her head sticks out one end and her feet stick out the other. The magician then spins the box, and when the feet are pointed away from the audience the assistant retracts her real feet and replaces them with a pair of fake feet. The lady is a contortionist, so she folds her legs into the upper part of the box and the magician "saws her in half." Because we saw the lady stick her feet through the holes, we assume they must be her feet the entire time, and the illusion is completely baffling!
These links will help you learn more: