Induction Heads as an Essential Mechanism for Pattern Matching in In-context Learning