If your stepper motor is jerking, not moving in the preset direction or during the change of direction of motion, then it might be that your stepper motor is not wired correctly. For example, consider a bipolar stepper motor such as Nema 17 stepper motor used widely for 3D printing. Bipolar stepper motor Nema 17 has 4 wires and these outside seen wires, which is usually colored black, green, blue and red are paired internally. Meaning each pair A and B has a wire going in/ out of the motor. The internal wiring of a bipolar stepper motor is shown below.
If you are confused which belongs to the 2 pairs, you can simply use a continuity tester or even a small sized LED. You have to put the LED legs to each two wires and rotate the motor. If the two wires being tested belongs to same pair then the LED will turn on.
Now the question of why stepper motor jerks is that, the current must be going into the motor from 1A and come out at 2A or vice versa for the first coil and the the current must be going into the motor from 1B and out from 2B or vice versa. But if your wires are connected such that the current source and termination is say 1A and 2B then there will be jerking, at least in my experience.
The connecting colored wire to the stepper motor may not align in the way it should be as explained above. So first you need to know which wire belongs to each other, then you have connect them to the source and termination.
Additional resources:
1. Stepper Motor Acceleration & Speed Control with Arduino
2. Nema 17 Stepper Motor Speed and Direction Control with Arduino