How Do Transformers Learn Variable Binding in Symbolic Programs?