The reason why it works like this, is actually pretty simple. As shaggles wrote, turning is all about leaning the bike to one side, and in order to do that, you turn the front wheel in the opposite direction.
Consider a book balancing on a table. If you want the book to fall to the left, you have two options. You can either push it to the left at the top, which of course will make it fall to the left. The other option is to push the bottom of the book to the right, which will also make it fall to the left (try it if it is not clear It is the same as pulling the carpet away under someone standing on it. They will also fall to the opposite side of where their feet are being pulled towards.
Now, when you are steeing a motorcycle, you cannot push it at the top so easily (well, you can use the footpegs at slower speeds, but when the speed is too high, this becomes increasingly difficult, due to the gyroscopic forces, trying to keep the bike standing up), so instead you can move the wheels away under the bike, like when you tipped the book over by pushing at the bottom. You of course do this by steering in the opposite direction of where you want the bike to lean.