Rockets can use different systems for attitude control (control thrusters, fins, gyroscopes, TVC, ...). Since you ask for the seconds after liftoff, the relevant system is TVC (Thrust Vector Control).
TVC basically means that the engines themselves can gimbal to change the direction of the thrust. This can influence the attitude of the rocket by inducing offcentered thrust.
Sensors recognize changes in your heading and send signals to the guidance computer. The rocket's guidance computer will then manipulate the gimbal and therefore counteract the offnominal course.
The Soyuz guidance systems are activated 60 mins prior to launch. Navigation and TVC therefore guide the rocket form the first second on to ensure the correct path while clearing the tower.
For orbital class rockets, there is no structure to ensure the rocket's path while clearing the tower. It can be seen on sounding rockets which have no active guidance and rely on fins for stabilization. Since fins don't work too well until the rocket reached some velocity, it launches along a sliding rod (examples: see first comment).