Why DSolve and NDSolve give different answer? [duplicate]

This question already has an answer here:

Consider these code, which solve the same equation using DSolve and NDSolve, why do they give different answer? I'm using version 11.0 on Windows 8.1.

eq = D[u[x, t], t] == D[u[x, t], x, x];
icsbc = {u[x, 0] == 1, u[0, t] == 0, u[1, t] == 0};

numer1 = NDSolve[{eq, icsbc}, u, {x, 0, 1}, {t, 0, 1}]

numer2 = NDSolve[{eq, icsbc}, u, {x, 0, 1}, {t, 0, 1},
Method -> {"MethodOfLines",
"SpatialDiscretization" -> "FiniteElement"}]

numer3 = NDSolve[{eq, icsbc}, u, {x, 0, 1}, {t, 0, 1},
Method -> {"MethodOfLines",
"SpatialDiscretization" -> {"TensorProductGrid",
"MinPoints" -> 200}}]

symbol = DSolve[{eq, icsbc}, u[x, t], {x, t}]

symbol = {{u[x, t] -> Inactive[Sum][-(( 2 (-1 + (-1)^K) E^(-\[Pi]^2 t K^2) Sin[\[Pi] x K])/(\[Pi] K)), {K, 1, \[Infinity]}]}}

Plot[{Evaluate[u[x, 1/2] /. numer1], Evaluate[u[x, 1/2] /. numer2],
Evaluate[u[x, 1/2] /. numer3],
Evaluate[(u[x, t] /. symbol[] /. t -> 1/2 /. {Infinity -> 10} //
Activate)]}, {x, 0, 1},
PlotLegends -> {"numeric1", "numeric2", "numeric3", "symbolic"},
PlotStyle -> {{Green, Dashing[{0.1, 0.1}], Thin}, {Blue,
Dashing[{0.05, 0.05}], Thin}, {Yellow, Dashing[{0.01, 0.01}],
Thin}, {Black, Thickness[0.02]}}] Another example:

L = 2;
eq = D[u[x, t], t] == D[u[x, t], x, x];
opts = Method -> {"MethodOfLines",
"SpatialDiscretization" -> {"FiniteElement",
"MeshOptions" -> {"MaxCellMeasure" -> 0.001}}};

sol1 = NDSolveValue[{eq, u[x, 0] == x, u[0, t] == 1, u[2, t] == 1},
u, {x, 0, L}, {t, 0, L}, opts];

sol2 = u[x, t] /.
First@DSolve[{eq, u[x, 0] == x, u[0, t] == 1, u[2, t] == 1},
u[x, t], {x, t}]

(* 1 + Inactive[Sum][-((
2 (1 + (-1)^K) E^(-(1/4) \[Pi]^2 t K^2)
Sin[1/2 \[Pi] x K])/(\[Pi] K)), {K, 1, \[Infinity]}] *)

T = 1/10;
Plot[{Evaluate[sol1[x, T]],
Evaluate[sol2 /. {Infinity -> 100} /. t -> T // Activate]}, {x, 0,
L}, PlotLegends -> {"numeric solution", "symbolic solution"}] 