To CoT or To Loop? A Formal Comparison Between Chain-of-Thought and Looped Transformers