Computation Mechanism Behind LLM Position Generalization