When developing Lagrangian formalism, it is essential to set generalized coordinates:
$ x_{i} = x_{i}(q_{j},t)$ where $t$ is time. $q$ is the generalized cooridnate we wish to use.
During derivation, we have to calculate this:
$\frac{d}{dt}\frac{\partial x_{i}}{\partial q_{j}}= \sum_{k}\frac{\partial^2 x_{i}}{\partial q_{k}\partial q_{j}}\dot{q}_{k} + \frac{\partial^2 x_{i}}{\partial q_{j}\partial t}$
Where $\dot{q} = \frac{dq}{dt}$
Not too sure why chain rule is applied in this case, but I'm guessing it's because of:
$\frac{d}{dt}\frac{\partial x_{i}}{\partial q_{j}} = \frac{d}{dt}\frac{\partial x_{i}(q_{j},t)}{\partial q_{j}}$
But I'm not too sure how that expands into the expression given above.
The chain rule for a 2 variable function $f(x(t),y(t))$ is $$\frac{df}{dt}=\frac{\partial f}{\partial x}\frac{dx}{dt}+\frac{\partial f}{\partial y}\frac{dy}{dt}$$
If your function $x$ depends on $q_1,q_2,...,q_n$ and $t$, then we generalize the above formula to include all the $q_k$'s. Let's say we want to find $\frac{d x}{dt}$: $$\frac{dx}{dt}=\frac{\partial x}{\partial q_1}\frac{dq_1}{dt}+\frac{\partial x}{\partial q_2}\frac{dq_2}{dt} +\cdots +\frac{\partial x}{\partial q_n}\frac{dq_n}{dt}+\frac{\partial x}{\partial t}$$
Doing the same thing for $\frac{\partial x}{\partial q_j}$ will give you the formula you have.
Hope this helps.