This is a common problem and your teacher was correct. In effect music is a mathmatical transaction. For the score to be excuted as written, first all the detail must be comprehended, then performance must be inhanced by an internal counter. Without that performances taper or accelerate by their own volition. Another issue comes from taking on extravegant complex passages where detail might be sacrificed to make performance possible.The common lesson/solution is very simple. 1st invest in a metronome and then slow problem passages down to an acceptable speed for performance even if that means you play "prestissimo" largo. Once all the elements come together mathmatically, you are rythmically correct and you can speed up the targeted sections. And for the commenter, "spontaneous rubato" sounds like the old addage "playing from the heart". Those who play from the heart amost invariably misrepresent it. Your problem is discipline - i.e. you lack it. Apply it and your music appreciation and output will eventually enthrawl. One of the positive messages I can give to those who play from the heart is it is you who have the passion to become fine interpreters. Fine technicians struggle with interpretation as a general rule. That is the real paradox.
Notation is a very crude graphic approximation to rhythm at the best of times and counting and metronomes are even cruder. Western notation and its centuries of hidebound tradition have created the persistent illusion that rhythm is a simple property of notation, when in fact most felt rhythms of any interest are very complex and cannot be notated at all. Having said that, if all you are playing is classical music, which hangs on notation anyway, and counting and metronomes help, then use them, but only as a crutch, a learning tool, until the complete rhythm is firmly in your mind.There is also a clear difference between feeling rhythm and being able to keep a regular beat; the latter is a very tiny subset of the former. I would be inclined not to worry about bending rhythms in traditional romantic music. Most of it would sound pretty trotty played metronomically wouldn't it ? Metronomic stride and swing, for example a Midi file, sounds okay, but even there, I get the feeling something is missing after a while, something which is vitally present in a solo by Waller, Morton and others. Rhythm to me lies at the core of music and like music itself, is ineffable in the sense that just when I think I understand a lot, it surprises and delights and tells me I understand very little. I rather enjoy this ongoing process.