To derive the local expression for the affine connection. Take a vector fields $X$ and $Y$, $X$ has local expression $X= \sum_j X^j\frac{\partial}{x_j}$, $Y$ has local expression $Y= \sum_j Y^j\frac{\partial}{x_j}$, then $\nabla_XY = \nabla_{\sum_j X^j\frac{\partial}{x_j}}\sum_j Y^j\frac{\partial}{x_j}$, why does this equality hold?
My confusion is that $X= \sum_j X^j\frac{\partial}{x_j}$ only locally, and $\sum_j X^j\frac{\partial}{x_j}$ is only a vector field on an open subset of the manifold, but affine connections are for vector fields defined on the whole manifold, I do not really see why the equality would hold, it does not make any sense to me.
To be more explicit. Take charts $(U,\phi)$ of $M$, then $\forall p \in U$, $X_p = \sum_j X^j\frac{\partial}{x_j}|_p$, which is obvious, then we would consider the vector field $\sum_j X^j\frac{\partial}{x_j}$ which is defined on $U$. So we examine $\nabla_{\sum_j X^j\frac{\partial}{x_j}}\sum_j Y^j\frac{\partial}{x_j}$, the confusion arises because $\nabla$ takes vector fields defined on $M$ rather than vector fields defined on $U$ as its input.