$\newcommand{\angles}[1]{\left\langle\,{#1}\,\right\rangle}
\newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
\newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
\newcommand{\dd}{\mathrm{d}}
\newcommand{\ds}[1]{\displaystyle{#1}}
\newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
\newcommand{\half}{{1 \over 2}}
\newcommand{\ic}{\mathrm{i}}
\newcommand{\iff}{\Longleftrightarrow}
\newcommand{\imp}{\Longrightarrow}
\newcommand{\Li}[1]{\,\mathrm{Li}_{#1}}
\newcommand{\ol}[1]{\overline{#1}}
\newcommand{\pars}[1]{\left(\,{#1}\,\right)}
\newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
\newcommand{\ul}[1]{\underline{#1}}
\newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
\newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
\newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
You are calculating for 'a given' $\ds{\,\mathrm{P}_{n}\pars{x}}$
$\ds{~\pars{\mbox{namely, for 'a given'}\ n}~}$. You must use another index for the generating function $\ds{~\pars{n\ \mbox{is a constant}}~}$ such as $\ds{m}$ which I'll use below !!!.
\begin{align}
&\color{#f00}{%
\int_{-1}^{1}\pars{1 - 2xt + t^{2}}^{-1/2}\,\,\,\mathrm{P}_{n}\pars{x}\,\dd x}
=
\int_{-1}^{1}\overbrace{%
\bracks{\sum_{m = 0}^{\infty}t^{m}\,\mathrm{P}_{m}\pars{x}}}
^{\ds{\pars{1 - 2xt + t^{2}}^{-1/2}}}
\,\mathrm{P}_{n}\pars{x}\,\dd x
\\[5mm] = &\
\sum_{m = 0}^{\infty}t^{m}\ \underbrace{%
\int_{-1}^{1}\,\mathrm{P}_{m}\pars{x}\,\mathrm{P}_{n}\pars{x}\,\dd x}
_{\ds{2\,\delta_{mn} \over 2n + 1}}\ =\
\color{#f00}{{2\,t^{n} \over 2n + 1}}
\end{align}