Voltage lower than expected with Nema 17 stepper motor and L298N
If the motor is still drawing 2 amps after it has stopped moving, then it is not off. Your code is telling the motor to hold position, which draws current, and will heat the motor up fast.

Unless you need torque to hold the position, change your code to power off all of the coils to the stepper.