This happens because of inertia—the tendency of an object to resist changes in its state of motion. When the horse stops suddenly, your body wants to keep moving forward at the same speed. Since you are connected to the horse, you are carried forward over its head.