Forget two wheels. Look at one wheel. Just take a wheel of any kind and roll it down a hill. It stays up until it stops rolling.
The reason is gyroscopic precession. If it starts to fall to the right, that is no different than if you strike it with your hand at the top on the left side.
The top of the wheel is moving forward, so when you strike it on the left side, you are deflecting the material on the top into a path that is angled to the right of its original direction. This has the effect of turning the wheel to the right, which (if the tilt was caused by falling to the right) brings its point of support back under its center of gravity. That's how it balances itself.
When it stops turning, this effect stops working.
A bicycle uses this effect, plus the rider also steers in the direction of fall. But a bicycle will stay up all by itself as long as it has any speed.