Derivation $X^2$-pdf (Chi square) for $k$ degrees of freedom
I assume your $X$ is an $N(0,1)$ random variable.
Let $X_1 \sim {\rm Gamma}(\alpha_1, \beta)$ and $X_2 \sim {\rm Gamma}(\alpha_2, \beta)$ be independent Gamma random variables with the same scale parameter $\beta$ (here we use the parametrization such that ${\rm E}[X_1] = \alpha_1 \beta$). Then the density of $Y = X_1 + X_2$ is given by $$\begin{align*} f_Y(y) &= \int_{t=0}^y f_{X_1}(t) f_{X_2}(y-t) \, dt \\ &= \int_{t=0}^y \frac{t^{\alpha_1 - 1} e^{-t/\beta}}{\Gamma(\alpha_1) \beta^{\alpha_1}} \cdot \frac{(y-t)^{\alpha_2 - 1} e^{-(y-t)/\beta}}{\Gamma(\alpha_2) \beta^{\alpha_2}} \, dt \\ &= \frac{e^{-y/\beta}}{\beta^{\alpha_1+\alpha_2}} \cdot \frac{1}{\Gamma(\alpha_1)\Gamma(\alpha_2)} \int_{t=0}^y t^{\alpha_1-1} (y-t)^{\alpha_2-1} \, dt \\ &= \frac{e^{-y/\beta}}{\Gamma(\alpha_1+\alpha_2) \beta^{\alpha_1+\alpha_2}} \cdot \frac{\Gamma(\alpha_1+\alpha_2)}{\Gamma(\alpha_1)\Gamma(\alpha_2)} \int_{u=0}^1 (yu)^{\alpha_1-1} (y(1-u))^{\alpha_2-1} y \, du \\ &= \frac{y^{\alpha_1+\alpha_2-1} e^{-y/\beta}}{\Gamma(\alpha_1+\alpha_2) \beta^{\alpha_1+\alpha_2}} \cdot \frac{\Gamma(\alpha_1+\alpha_2)}{\Gamma(\alpha_1)\Gamma(\alpha_2)} \int_{u=0}^1 u^{\alpha_1-1} (1-u)^{\alpha_2-1} \, du \\ &= \frac{y^{\alpha_1+\alpha_2-1} e^{-y/\beta}}{\Gamma(\alpha_1+\alpha_2) \beta^{\alpha_1+\alpha_2}}, \end{align*}$$ where we see that the last integral is simply that for a beta density over its support. Thus $Y \sim {\rm Gamma}(\alpha_1 + \alpha_2, \beta)$, as claimed.