This is due to inertia. Inertia is a property of matter by which it continues in its existing state of rest or of uniform motion unless acted upon by a net unbalanced external force. When brakes are applied, our leg suddenly comes to a stop but our upper body continues to move forward because of inertia. Hence we lean forward.