As mentioned trail and chainstay length are important factors but I recently noticed that moving my saddle forward made it much more stable with no hands.
I didn't have a problem before mind you but now it's effortless and I never have to make broad corrections if that makes sense. Don't go moving your saddle just for this reason though, I was playing with saddle fit for some knee tenderness and comfort and as a byproduct noticed the increased hands-free stability.