Emergent neural dynamics and geometry for generalization in a transitive inference task