I'm struggling with the following:
Suppose that we have a formal power series $\sum_{n \geq 0} a_nx^n$ which is equal to the fraction $\frac{2-6x+x^2}{1-3x}.$ I want to find an explicit formula for $a_n.$
Here is what I have done so far: I realise that $(1-x)^{-n} = \sum_{k \geq 0} {n + k - 1 \choose k}x^k,$ so I can say that $\frac{2-6x+x^2}{1-3x} = (2-6x+x^2)(1-3x)^{-1} = (2-6x+x^2)\sum_{k \geq 0} {k \choose k} x^k.$
From here we obtain
$ \sum_{k \geq 0} 2x^{k} - \sum_{k \geq 0} 6x^{k+1} + \sum_{k \geq 0} x^{k+2}.$
Here I have no clue how to continue or if I'm even on the right track. Hints and or solutions are very welcome
Your method is perfect, except that you forgot the factor $3$: $(1-3x)^{-1}=\sum_{k=0}^\infty({\color{red}3}x)^k$, hence
$$\frac{2-6x+x^2}{1-3x}=\sum_{k\ge0}2\cdot3^kx^k-\sum_{k\ge0}6\cdot3^kx^{k+1}+\sum_{k\ge0}3^kx^{k+2}$$ $$=\sum_{k\ge0}2\cdot3^kx^k-\sum_{m\ge1}6\cdot3^{m-1}x^m+\sum_{n\ge2}3^{n-2}x^n$$ $$=2+\sum_{n\ge2}3^{n-2}x^n.$$
Remark. If you first notice that the numerator is $2(1-3x)+x^2$, you get directly:
$$\frac{2-6x+x^2}{1-3x}=2+\sum_{k\ge0}3^kx^{k+2}=2+\sum_{n\ge2}3^{n-2}x^n$$