Landing of a rocket seems impossible with vertical flight control only. How the rocket achieves horizontal flight control with engines in line with the booster?
The engines, like engines on most large launchers, are gimbaled to steer in any direction. By rapidly adjusting the gimbal angle, the rocket can stay balanced vertically while adjusting its path horizontally.
The Falcon 9 also has aerodynamic grid fins at the top of the first stage, which provides steering control throughout the unpowered portion of the reentry and return flight.
Finally, the Falcon also has pressurized nitrogen thrusters at the top of the stage which it can use for steering. These are primarily intended for use at very high altitude, where the air is so thin that the fins aren't effective, but they're still potentially useful all the way to touchdown.