Friction is always in the opposite direction to the direction of movement of an object.
It opposes the RELATIVE motion the object has to say, the underlying surface.
Friction seeks to equalize the motions of the object and the surface.
Suppose you drop a brick (no horizontal velocity) onto a moving plank.
The friction from the plank will accelerate the brick in the direction of its own generated horizontal motion, until the brick moves with the same speed as the plank.