hmm no idea really... uploaded your code and it works just fine.
I see two possible options
- Try lowering speed and acceleration as the motors move better in one direction that the other so my only guess is that it is stalling.
- Your wiring is incorrect