We see that the velocity at A and B are same and it takes 2 s to cover this distance.
Now it takes 2 s more to come back to B after travelling to the extreme position.
We see that the distance covered from A to B and then from B and then back to B from extreme takes 4 s. This is half the distance in the whole top and fro path. Thus the time taken for one oscillation should be 8 s