Did you purchase this TRX500 new or used? Have the hubs, rims or tires been changed? Has axle been replaced?
Any damage to the axle splines or axle nut threads can cause this. Also, axle nuts are not one size fits all so it's possible, if you bought the bike used, it has the wrong nut. If you changed the axle the old castle nut might not be a good fit.
If you have it slightly cross threaded this can cause the nut to jump a thread and work its way off.
Also, check the inside seal on the hub and be sure it is seated correctly.