The spinal cord runs in two directions: towards the brain (receptors) and down to the muscles (effectors). An upwards-running pathway, called the spinothalamic tract, detects pain and temperature. There are both hot and cold receptors in the skin. When you touch something extremely hot, it can cause ‘over-stimulation’, meaning that both hot and cold receptors are activated, as well as pain receptors.
If the cold message travels back to your brain first, it will get there moments before the hot sensation. However, this phenomenon certainly doesn’t affect everyone. No matter what you sense, a reflex arc will stimulate your muscles and force you to withdraw your limb in under a second.