The solution that you found is wrong, as it is discontinuous. We get a continuous solution if we give a bounded interval as domain forĀ t
:
sol = With[{a = 1, b = 1, x0 = 1, v0 = 0},
DSolveValue[{a*x''[t] + b*x'[t] == SquareWave[t], x[0] == x0,
x'[0] == v0},
x, {t, 0, 5}]];
PiecewiseExpand[sol[t]]
Plot[sol[t], {t, 0, 5}]