So glad he's doing better!
And personally, I believe while he doesn't actually comprehend what a doctor is, he is aware that you are bringing him to the mean, stabby human and then he feels better and is able to associate the two, just not at our level. Our pets are way smarter than people give them credit for.