Recall that we are trying to describe the solution space of
$$
Lf = \prod_{j = 1}^s (D-a_j)^{r_j} f = 0 \tag L
$$
Any answer will have to at least deal with the case $s = 1$.
Lemma 1: The solution space of
$$(D-a)^r f = 0 \tag{*}
$$
has basis $B = \{x^\ell e^{a x} : 0 \le l \le r-1\}$.
Proof: By induction on $r$. The case $r = 1$ requires solving $f' = a f$, whose general solution is $f = C e^{a x}$. For $r > 1$, $(D - a)^r f = (D-a)^{r-1} (D-a) f$, so if $f$ is a solution to (*), then $g = (D - a)f $ is a solution to
$ (D-a)^{r-1} g = 0$. By the induction hypothesis $g$ is in the span of $\{ x^\ell e^{a x} : 0 \le \ell \le r-2\}$. So now we have to solve the inhomogeneous first order equation $(D - a) f = g$ for $g$ in the span of $\{ x^\ell e^{a x} : 0 \le \ell \le r-2\}$. By inspection one can find a particular solution in the span of $B$, and the general solution is the sum of the particular solution and
$C e^{a x}$, which completes the proof that $B$ spans the solution space. Linear independence of $B$ is left to the reader.
Now it remains to consider the general problem $s > 1$.
The first method is going to look quite abstract and therefore pedagogically impossible because of fancy terminology, but I will remark that in fact it is very concrete, or could be made very concrete if one wanted to expend the time and effort.
Method 1. Let $s > 1$ and let $V$ be the solution space of $(\rm L)$. Also write $V_{a, r}$ for the solution space of $(*)$. Then $V_{a, r} \subseteq V$. Write $p(t) = \prod_{j = 1}^s (t -a_j)^{r_j}$.
$V$ is a torsion module over $\mathbb C[t]$ with period $p$, where polynomials act on $V$ by
$$
q \cdot h = q(D) h.
$$
By the primary decomposition theorem for torsion modules,
$$
V = V_{a_1, r_1} \oplus V_{a_2, r_2} \oplus \cdots \oplus V_{a_s, r_s},
$$
and thus we are done.
Discussion: the proof of the primary decomposition theorem is actually quite concrete and computational and depends on the following fact, which would be a useful thing for even undergraduates in science and engineering to see. For each $k$, let $q_k(t) = \prod_{j \ne k} (t -a_j)^{r_j}$. Then the collection of polynomials $q_k$, $1 \le k \le s$ has no non trivial common factor. It follows that one can compute, by repeated use of the Euclidean algorithm (Smith Normal Form for a one row matrix) polynomials $s_k(t)$ such that
$$
1 = \sum_k s_k(t) q_k(t).
$$
Thus for $f \in V$,
$$
f = \sum_k s_k(D) q_k(D) f.
$$
Since $q_k(D) f \in V_{a_k, r_k}$, this already shows that $V$ is spanned by $\{ V_{a_k, r_k}\}$. Linear independence is shown by a variation of the same idea.
Nevertheless, it seems quite unlikely that anyone is going to actually do this in an elementary course, so this observation is mostly for the enjoyment of people who are already comfortable with the primary decomposition.
Method 2:
For this method, let us prepare the following lemma.
Lemma 2: Consider $a \ne b$. The space $V_{b, r}$ is invariant under $D -a$, and $D-a$ is invertible on $V_{b, r}$, with an explicitly computable inverse.
Proof: $V_{b, r}$ is invariant under $D-a$ since $D-a$ commutes with $D -b$.
\begin{equation}
D- a = (D - b) + (b-a) = (b - a) \left [ 1 - (a-b)^{-1} (D - b) \right ]
\end{equation}
Now $N = (a-b)^{-1} (D - b) $ is nilpotent of order $r$ on $V_{b, r}$, and therefore $D-a$ is invertible with inverse
$$
(b-a)^{-1}(1 + N + N^2 + \cdots + N^{r-1}).
$$
Remark: One can recover this result by the more naive approach of assuming, for given $g \in V_{b, r}$ a solution $h \in V_{b, r}$ to the equation $(D-a) h = g$, and solving by matching coefficients.
Now we continue with the 2nd method. Suppose that $f$ is a solution of $(L)$. Write $a = a_1$ and $r = r_1$
Then $g = (D-a)^r f$ is a solution to
$$
\prod_{j > 1} (D - a_j)^{r_j} g = 0.
$$
By the appropriate induction hypothesis, it follows that $g \in V_{a_2, r_2} \oplus \cdots \oplus V_{a_s, r_s}$. Therefore $f$ satisfies the inhomogeneous DE
$$
(D-a)^r f = g,
$$
with $g \in V_{a_2, r_2} \oplus \cdots \oplus V_{a_s, r_s}$. Using Lemma 2, a particular solution $f_1$ can be found with $f_1 \in V_{a_2, r_2} \oplus \cdots \oplus V_{a_s, r_s}$. The general solution to $(L)$ is
$f = f_0 + f_1$, where $f_0$ is a solution to the homogenous equation $(D-a)^r f_0 = 0$, i.e. $f_0 \in V_{a_1, r_1}$. The conclusion is that $f$ is in the span of $\{V_{a_k, r_k} : 1 \le k \le s\}$.
For linear independence, suppose that $f_k \in V_{a_k, r_k}$ for each $k$ and $\sum_k f_k = 0$. Again writing
$a = a_1$ and $r = r_1$, apply $(D-a)^r$ to get
$\sum_{k \ge 2} (D-a)^r f_k = 0$. By an appropriate induction hypothesis, the spaces $V_{a_k, r_k}$ for $k \ge 2$ are linearly independent, so for each $k \ge 2$, $ (D-a)^r f_k = 0$. By the invertibility of $(D-a)^r$ on each
$V_{a_k, r_k}$ for $k \ge 2$, it follows that $f_k = 0$ for $k \ge 2$. Hence $f_1 = 0$ as well.