Nonlinear dynamics and loop formation in Kirchhoff rods with implications to the mechanics of DNA and cables