I'm going to suppress the sum over different chemical potentials for simplicity as it doesn't materially affect the argument. If we write $U$ as a function of $S,V,N$, then extensivity of $U$ is mathematically defined as follows
$$
U(\lambda S, \lambda V, \lambda N) = \lambda U(S, V, N)
$$
Physically, this is saying that if you scale the quanities that characterize your physical system by a certain amount, then the energy scales by the same amount. The mathematical terminology for this is that $U$ is a homogeneous function of degree $1$ in $S$, $V$, and $N$. Now, there is a theorem on homogeneous functions called Euler's homogeneous function theorem which (up to a technical assumption or two) states that a function $f:\mathbb R^n \to\mathbb R$ is homogeneous of degree $k>0$, namely
$$
f(\lambda x) = \lambda^kf(x)
$$
if and only if
$$
k f(x)=x\cdot \nabla f(x)
$$
Since the energy is a homogeneous function of degree 1, this theorem tells us that
\begin{align}
U(S,V,N)
&= (S,V,N)\cdot \nabla U(S,V,N) \\
&= S\left(\frac{\partial U}{\partial S}\right)_{V,N} + V\left(\frac{\partial U}{\partial V}\right)_{S,N} + N\left(\frac{\partial U}{\partial N}\right)_{S,V}
\end{align}
On the other hand, the fundamental thermodynamic relation you wrote (as the first equation) above allows us to identify
\begin{align}
\left(\frac{\partial U}{\partial S}\right)_{V,N} &= T\\
\left(\frac{\partial U}{\partial V}\right)_{S,N} &= -P\\
\left(\frac{\partial U}{\partial N}\right)_{S,V} &= \mu
\end{align}
so that we get the desired result:
$$
U(S,V N) = TS - PV + \mu N
$$