Understanding Catastrophic Forgetting in Language Models via Implicit Inference