(by:http://socrates.berkeley.edu/~fajans/Teaching/MoreBikeFiles/BikeQuestions.htm)
The simplest way to explain how you balance a bicycle is to make an analogy with the way you balance a stick on your palm. For example, suppose that the top of the stick tilts and starts to fall to the right. To regain balance, you move your hand to the right, thereby moving the bottom of the stick underneath the top. As the stick is no longer tilted, it stops falling. (Actually, you move your hand rightward just a bit further so that the stick tilts left a bit. This ends the rightward momentum of the stick, and allows you to move your hand back left, closer to you, a moment later.)
If you are riding a bike, and you start to fall to the right, you do exactly the same thing; you steer right, thereby driving the wheels directly underneath you again. Now you are no longer tilted, so you stop falling. (Once again, you actually overcompensate, so that you are tilted to the left. This stops the rightward momentum, and allows you to steer back left a moment later.)
Thus, balancing a bike is a process of making successive right and left turns. Typically these turns are very small, but can be easily seen in the tracks of a bike ridden on sand. The two tracks (from the front and rear wheels) weave in and out as the rider makes these small turns.
Riding a unicycle is very similar.