Why does resonance occur in a mass-spring system when the natural frequency = the driving frequency. I think it is because the driving force is always contributing to the kinetic energy of the system rather then acting against it i.e. the driving force is in phase with the velocity of the system, or is there another explanation?
You are correct. When the forcing frequency is equal to that of the natural frequency then the external force is constantly doing positive work on the system, which results in resonance.
When the forcing frequency is not equal to the natural frequency, then there are times when the force is contributing positive work (adding kinetic energy), and times when the force is contributing negative work (removing kinetic energy). Therefore resonance will not occur.