I am not the smartest guy in the room, no question there BUT I do know the whole losing home in a stepper based CNC has only a few causes. Especially with AvidCNC systems;
1. Double check the speeds in Mach4 and that they match your CAM . AvidCNC does tweak things. Drives me nuts but I guess they are trying to improve things.
2. Check your tensioner bolt. The bracket it passes through after the spring can get twisted and cause the rack and pinion to no longer mess correctly. Best way to check is to push the axis with the motors engaged and there should be no play. See if the tensioner bolt can be pushed in and the pinion gear is pushed off the rack. Release the tensioner bolt and make sure it full seats back against the rack.
3. Sanity check the speed and feeds in your CAM again! Lol, my problem is fat fingers.
4. The Z axis from AvidCNC can wear out the brake and that will cause you to lose steps in the Z.
Best of luck!
I hate typing in phones