That's actually quite disturbing. I'm glad you found it before it caught fire.
Last summer, maybe in August, when my AC was running the most, I had noticed my 30Amp plug was slightly warm at both ends. The cord contacts on the male end and the contacts in the PC's power wall socket were somewhat corroded.... But not loose like yours. I shut off the breakers inside and used some 200 grit sand paper very lightly to shine them up and then applied a very thin coat of silicone lube to prevent any further oxygen exposure and corrosion. Since that I've never found it warm. I fear the contacts inside the cord's socket end are corroded too, but I couldn't figure out how to get it open to verify. Checking this is now an action on my annual maintenance list. I'll add to check that the parts are tight as well.
I know that corrosion is a better resistor than conductor. In your case the lose contacts were the resistor. Happy you discovered it when you did. Thanks for the alert.
Larry