This is common corner cutting with Chinese machines, chances are the 2 motors share just one drive has well.? Bad bad idea just asking for error and trouble.!!

First of all Mach3 doesn't support closed loop so fitting encoders won't help here. Mach will read encoders and show encoder position in a DRO but can't act or do anything other than that.

I have a couple of suggestions.!! All include dumping NCstudio and using Mach3 using the parallel port or if you want better stability and higher speeds using motion control card like Ethernet smooth stepper.

First getting round the racking or should say minimising the chances of it happening and preventing damage if it does.
The most common cause of missed or lost steps and then subsequent racking with twin motors is over tuning the motors and pushing them far to close to the corner speed where torque drops away.
Often what happens is the motors don't stall but they don't have enough torque to hold position when deaccellerating or accelerating hard so get pushed along thru inertia effectively losing position by step here or there. This then accumulates over the course of the job to such a point the racking affect stalls the gantry.
The easy solution and really the only way to be sure racking doesn't happen with twin motors is to de-tune the motors and run them well below the motors corner speed. The problem then comes from lower speeds for cutting or rapids.!!
The solution to this is to use higher pitch screws and gear them so the motors can run at lower speed where torque is higher and still give reasonable speed and resolution.!! . . . . . All easy enough if your building from scratch but not so easy if your stuck with existing screws.!!

So the next best thing is to use Good digital drives that have Stall detection built into them like leadshine AM882, these drives have a fault output signal which can then be tied into the control E-stop system and stop the machine when it sees stall happening. They won't show missed steps or correct for missed steps but they will detect when motor is stalling and protect the machine from doing damage thru racking. They are also very good drives for resonance and just very nice drive in general.

The next option is to use the Hybrid servo stepper system which is actually closed loop stepper system but closed by the drive not the Control so will work fine with mach3 or any control that doesn't have closed loop capability's.
This system will not run out of position and will correct for positional error if it does. It works very much like a servo system but use's stepper motors with encoders meaning it keeps the cost down.
The drives can be setup with fault tolerance values so if the positional error becomes too great, say thru inertia pushing gantry etc, then outputs a fault command which can again be incorparated into the E-stop system bring the whole machine to safe stop.
Now they are expensive compared to standard steppers/drives but cheaper than Servo's. . . .Now often folks think Servo's are better than steppers but this actually isn't the case for machines that don't require high speeds or carry heavyloads.
Steppers if run correctly can be just has accurate and reliable, plus much much simpler to setup and keep running compared to servos.
Also with control software like Mach3 that don't support closed loop they don't actually offer any advantage over steppers has they won't correct for positional error.? They will report positional error and servo drives can be setup to fault if exceeds programmable settings but other than that they offer no advantage. . . . .This is where the hybrid servo stepper wins because it closes the loop internally and corrects for positional error has well has faulting if greater than set parameters.. . Win win.
They are also Digital drives so very good regards resonance handling and very simple to setup with none of the tuning issues servo drives can come with.

Some where on this forum and utube I posted video showing testing hybrid system, check it out.

Hope this helps.!!

PS: . . .Oh the other way to completely eliminate racking is to connect screws with timing belts and use Single large motor like I do on my machine. In over six years I've not dropped one step(thru sensible tuning) or lost position ever (except thru my own error) and the gantry is perfectly square because screws are always kept perfectly in sync so gantry just can't rack. I've run jobs that lasted 30+ hours without stopping and when finished sent home and be perfectly back where it started.!!