Mcp23017 getting very hot within seconds

I think you should double check the IC's pins then check everything with a multimeter. Check you power source as well for it may be giving too much power. After that maybe you can add a resistor or something. Also do you have a circuit diagram, if so can you send that as well?