Hello Agapi Pop,
to make your code run you need to rewrite the second line like so:
t = First[p /. Solve[p - 2 i == 0]];
This is, because here the result of Solve
is a List
containing one element, and you want that element only.
But - if I may add - a more Mathematica like coding would read:
t = Flatten@Table[p /. Solve[p - 2 i == 0, p], {i, 1, 4}];
s = NDSolveValue[{y'[x] == #*y[x] Cos[x + y[x]], y[0] == 1}, y, {x, 0, 30}] & /@ t;
Plot[Evaluate@Through[s[x]], {x, 0, 30}, PlotRange -> All]
(* or likewise: *)
Plot[#[x], {x, 0, 30}, PlotRange -> All] & /@ s
