Competition Dynamics Shape Algorithmic Phases of In-Context Learning