Out-of-Distribution Generalization of In-Context Learning: A Low-Dimensional Subspace Perspective