We are seated in a bus. Then the part of the body which is in firmly contact with the bus, is traveling with the speed of the bus at each instant. The friction between the bus and the body ensure that.
The other parts of the body, like upper part of torso or head which are not in firm contact with the bus, are not immediately following the speed of the bus. When the brakes are applied to stop, these parts of the body try to continue moving forward. This phenomenon is called the inertia of motion. Hence, the upper part of the body still continues to move ahead and falls forward. But due to the cohesion force between the body parts , the body quickly attains the speed of the bus.
When a bus suddenly accelerates from rest, the upper part of the body still tries to remain in the state of rest (inertia of rest). So we move backwards. Then the cohesive forces in the body cause the upper part of the body to gain the speed of the bus.