Hi, I can not spot a bug in the code, but there are a few things that got my attention.
A Raspberry Pi with a Arduino Nano and a stepper motor, those three together can already give a lot of problems.
Is the current for the stepper motors somehow influencing the Arduino Nano ? Perhaps with a ground current ? Can you tell how that is connected ?
How did you connect the GND of the Raspberry Pi to the GND of the Arduino ? The I2C has three wires: SDA, SCL and GND.
The Raspberry Pi runs at 3.3V and the Arduino Nano at 5V. How did you connect a 3.3V I2C bus to a 5V I2C bus ? How long are the wires for the I2C bus ? Do you use a cable for the I2C bus ? Do you use pullup resistors and what is their value ? It is possible that the I2C bus is stuck, so you have to get that right.
In the sketch, you don't have to include stdio.h and stdlib.h. Please remove those.
In the i2c_receive() function there is a question if the bytes should be read.
There is no need to read the bytes. The I2C works with packages of data. You can ignore the data and the next time you receive a new package.
In the sketch you do a while-loop until the stepper motor has reached the targe position. During that, it is hard to do other things. You break out of that while-loop if a new command was given via I2C. That makes the code harder to understand.
Would accelStepper make the sketch easier ?
I put all of your code in a single file. It is less than 300 lines, that's not so bad.
When you want to have smaller files, then I suggest to keep the global variables, the setup() and the loop() in the main *.ino file and move functions into other files.
When I turn on the all the warnings in the settings, then it gives warnings for the i2c_request() function. Did you forget a few "break ; " ? I think you always return 3 bytes and only 0x01 and 0x02 have a break.
Why did you choose the I2C bus to communicate with the Arduino ? When the Arduino board is connected with the USB bus, then you can use the Serial bus. There is a library to communicate using Python: GitHub - PowerBroker2/pySerialTransfer: Python package to transfer data in a fast, reliable, and packetized form.