That looks like the epoxy resin they use to balance the motors. If you have a look at the lower or upper part of the magnets you will see a little bit of this substance on basically every motor. Unless the motor is perfectly balanced by conincidence, which is highly unlikely, you will need some of it in order to get rid of any vibrations.
In your case it looks very unusual. If it is actually this balancing compound, it seems like they have "repaired" a motor which would otherwise have been scrap.
I have no idea what else would get in the motor like this. If the motor gets warm enough to melt plastic, something is wrong.