Suppose we have two bodies A and B moving with velocities v a and v b respectively.
Then the relative velocity of A w.r.t B is given by, v a,b = v a - v b
And the relative velocity of B w.r.t A is given by, v b,a = v b – v a
Thus relative velocity of a moving body, A, with respect to another moving body, B, is found by considering B to be fixed and then finding the velocity of A which an observer resting on B will observe.
When A and B are moving the the same direction and their respective velocities are va and v b . Then, the relative velocity of A w.r.t B is given by, v a,b = v a - v b
And the relative velocity of B w.r.t A is given by, v b,a = v b – v a
When A and B are moving towards each other. The velocity of A will be v a and the velocity of B will be –v b . The negative sign appears because the direction of velocities are opposite.
So, relative velocity of A w.r.t B is, v a,b = v a – (-v b ) = v a + v b
And the relative velocity of B w.r.t. A is, v b,a = -v b - v a = -(v a + v b )