That's only true if the pde is linear.
Consider the equation
[tex]U_{xx}= U_{tt}[/tex]
with boundary conditions U(0, t)= 0 and U(L, t)= 0 and initial conditions U(x, 0)= f(x), Ut(x, 0)= 0.
If U(x,t) and V(x,t) are two functions satisfying that equation and a and b are any two numbers, then [itex](aU+ bV)_{xx}= aU_{xx}+ bV_{xx}[/itex] and because U and V satisfy [itex]U_{xx}= U_{tt}[/itex] and [itex]V_{xx}= V_{tt}[/itex], we can write that as [itex]aU_{tt}+ bV_{tt}= (aU+ bV)_{tt}[/itex] so that [itex](aU+ bV)_{xx}= (aU+ bV)_{tt}[/itex]. That is, aU+ bV satisfies the same differential equation.
If we let U= T(t)X(x) (separate it into a function of t only and a function of x only) we get
[tex]TX''= T''X[/tex]
which we can rewrite as
[tex]\frac{X''}{X}= \frac{T''}{T}[/tex]
Since the left side depends only upon x and the right depends only on t, in order to be equal for all x and t, the two sides must be equal to the same constant.
That is,
[tex]\frac{X''}{X}= \frac{T''}{T}= \lambda[/tex]
for some constant [itex]\lambda[/itex].
That gives us the two equations [itex]X''= \lambda X[/itex] and [itex]T''= \lambda T[/itex].
Further, U(0, t)= X(0)T(t)= 0. Either T(t)= 0 which would mean U(x, t)= 0 for all x and t, or X(0)= 0. In order that this problem have a non-trivial solution, we must have X(0)= 0. Also U(L, t)= X(L)T(t)= 0 gives X(L)= 0.
To solve [itex]X''(0)= \lambda[/itex] with boundary conditions X(0)= 0, X(L)= 0, consider possible values for [itex]\lambda[/itex]
1) If [itex]\lambda= 0[/itex], we have [itex]X''= 0[/itex] which has general solution X(x)= Ax+ B. Then X(0)= B= 0 and X(L)= AL+ 0= 0 so A= 0. X must be identically 0 which means U must be identically 0 which means we cannot match the initial conditions.
2) If [itex]\lambda> 0[/itex], we can write [itex]\lambda= \alpha^2[/itex] with [itex]\alpha\ne 0[/itex]. Now the equation is [itex]X''= \alpha^2X[/itex] which has general solution
[tex]X(x)= Ce^{\alpha x}+ De^{-\alpha x}[/tex]
[tex]X(0)= C+ D= 0[/tex]
[tex]X(L)= Ce^{\alpha L}+ De^{-\alpha L}= 0[/tex]
From the first equation, D= -C so the second equation becomes
[tex]Ce^{\alpha L}- Ce^{-\alpha L}= C(e^{\alpha L}- e^{-\alpha L})= 0[/tex]
But one of those exponentials is greater than 1 while the other is less than 1. The difference cannot be 0 which means we must have C= 0 and then D= 0. Again, that is the trivial solution which we cannot use.
If [itex]\lambda< 0[/itex], we can write [itex]\lambda= -\alphaa^2[/itex] with [itex]\alpha\ne 0[/itex]. Now the differential equation for X is [itex]X''= -\alpha^2X[/itex] which has general solution
[tex]X(x)= C cos(\alpha x)+ D sin(\alpha x)[/tex]
[tex]X(0)= C= 0[/tex]
[tex]X(L)= D sin(\alpha L)[/tex]
The only way to avoid D= 0 and another trivial solution is to have [itex]sin(\alpha L)= 0[/itex] which means [itex]\alpha L[/itex] must be a multiple of [itex]\pi[/itex]: [itex]\alpha L= k\pi[/itex] so [itex]\alpha= k\pi/L[/itex] for integer k.
But then
[tex]X(x)= C sin((k\pi/L)x)[/tex]
satisfies the differential equation
[tex]X''= -(k\pi/L)^2X[/tex]
and the boundary condition X(0)= 0, X(L)= 0 for any C or integer k.
Now that we know [itex]\lambda= -\alpha^2= -(k\pi/L)^2[/itex] we can write the differential equation of T as
[tex]T''(t)= -(k\pi/L)^2T(t)[/tex]
which also has general solution
[tex]T(t)= Acos((k\pi/L)t)+ B sin((k\pi/L)t)[/tex]
Now, one of the intial conditions is [itex]U_t(x, 0)= X(x)T'(0)= 0[/itex] which means that we must have
[tex]T'(0)= -A(k\pi/L)sin((k\pi/L)0)+ B(k\pi/L)cos((k\pi/L)0)= B(k\pi/L)= 0[/tex]
so B= 0.
But the other intial condition, [itex]U(x, 0)= f(x)[/itex] cannot be separated in that way.
What we have so far is
[tex]U(x,t)= X(x)T(t)= AC sin((k\pi/L)x)cos((k\pi/L)t)[/tex]
and so
[tex]U(x, 0)= C' sin((k\pi/L)x)= f(x)[/tex]
where I have written C' for AC.
Now for some functions, f(x), that can easily be done- if [itex]f(x)= 4sin((3\pi/P)x)[/itex] it is easy to see that we can set C'= 4 and k= 3 to get
[tex]U(x, t)= 4sin((3\pi/L)x)cos((3\pi/L)t)[/tex]
But what if f(x) were some more complicated function? Say, f(x)= x(L- x) (chosen so that f(0)= 0, f(L)= 0)? Because, as I showed above, sums of solutions to the equation also satisfy the equation, what we can do in that case is combine the solutions for all integer values of k:
[itex]U(x, t)= \sum_{k=0}^\infty C_ksin((k\pi/L)x)cos((k\pi/L)t)[/itex]
and try to find [itex]C_k[/itex] such that
[itex]U(x, 0)= \sum_{k=0}^\infty C_k sin((k\pi/L)x)= x(L- x)[/itex]
That is precisely the "Fourier series" solution.