@user10478 the solution is really as small as you can get it. But if you want to expand it, you can try
pde = D[u[x, t], t] == D[u[x, t], {x, 2}] + x + t;
bc = {u[0, t] == 0, u[5, t] == 0}
ic = u[x, 0] == 0;
sol = u[x, t] /. First@DSolve[{pde, bc, ic}, u[x, t], {x, t}]
sol = sol /. K[1] -> n
sol[[1]] = sol[[1, 1 ;; 3]]* Expand[sol[[1, 4]]]*sol[[1, 5]]
and now it is expanded.
pde = D[u[x, t], t] == D[u[x, t], {x, 2}] + x + t;
bc = {u[0, t] == 0, u[5, t] == 0}
ic = u[x, 0] == 0;
sol = u[x, t] /. First@DSolve[{pde, bc, ic}, u[x, t], {x, t}]
sol = sol /. K[1] -> n
sol[[1]] = sol[[1, 1 ;; 3]]* Expand[sol[[1, 4]]]*sol[[1, 5]]
and now it is expanded.