Need to synchronize stepper motors
The problem is that a Raspberry runs a kernel (linux) and you do not have direct access to the IO nor have full CPU process.

This results to a undefined, variable random delay to your IO access and is not easy to solve on a Raspberry.

If your raspberry has several CPU Core, you can reserve one core to a specific task, so you won't have kernel task switch over and you can then control your timings. You probably also would need some kernel level drivers to access the IO directly from your separate core, if that is possible. All this is not an easy feat.

The easier method would be to control your PWM with an Arduino, and connect the arduino to the raspberry through SPI/I2C, this approach will be much simpler and you will be able to accurately control and synchronize your PWM and the motor.

Here a link for motor drive system with arduino.