AddForce issue after rotation of the object axis

Please check out this page for how to post code nicely on the forums: Using code tags properly

One idea is that you can freeze the rotation (in the inspector) for the cube’s rigidbody. This will prevent it from flipping on its own.

You should be aware, as you’re new, that it’s generally not a good idea to do regular movement with the transform, if you have a rigidbody on your game object. You should be using add force or modifying the velocity and letting the physics engine handle it for you. Moving the transform bypasses the physics engine.