IMHO, the simplest way is to obtain the matrix $M$ of $L$ with respect to the basis $\{1,x,1+x^2\}$
Here is how.
$L(1)=0=0+0x+0(1+x^2)$, thus associated with coefficients $(0,0,0)$ for the first column of $M$.
$L(x)=x=0+1x+0(1+x^2)$, thus associated with coefficients $(0,1,0)$ for the second column of $M$.
$L((1+x^2)=2(1+x^2)=0+0x+2(1+x^2)$, thus associated with coefficients $(0,0,2)$ for the third column of $M$.
Thus
$$\tag{1}M=\pmatrix{0&0&0\\0&1&0\\0&0&2} \ \ \iff \ \ \pmatrix{0&0&0\\0&1&0\\0&0&2}\pmatrix{a_0\\a_1\\a_2}=\pmatrix{0\\a_1\\2a_2}$$
Remark: the second form of (1) could have been obtained directly.
As a consequence of (1), $$M^n=\pmatrix{0&0&0\\0&1&0\\0&0&2^n} \ \ \iff \ \ \pmatrix{0&0&0\\0&1&0\\0&0&2^n}\pmatrix{a_0\\a_1\\a_2}=\pmatrix{0\\a_1\\2^na_2}$$
which is equivalent to say that:
$$L^n(a_0+a_1x+a_2(1+x^2))=a_1x+2^{n}a_2(1+x^2)$$