If your stepper motor is supposed to run on 5V supply then you should not connect it to 24V. Using a resiser to limit the current is not a good solution.
The 2.2K resistor we recommend is for interfacing to the stepper DRIVER input, not the stepper motor itself. You have to try to understand the differences between the two. The stepper driver may be using 5V for its input interface but the stepper motor itself may be powered by 5V, 9V, 12V, 24V or even 48V and these voltages are normally independent or isolated from the 5V interface input.