Learning by Steering the Neural Dynamics: A Statistical Mechanics Perspective