Even though the Method of Undetermined Coefficients is usually taught as a method for solving nonhomogeneous linear ODEs with constant coefficients, it seems to also work if the coefficients are not constant. For example, let
$$ t^2y''-2y=t. $$
The solution to the associated homogeneous equation, $t^2y''-2y=0$, is spanned by the functions $t^2$ and $t^{-1}$. Using the Method of Undetermined Coefficients, one can guess a particular solution of the form $y_p(t)=At+B$, where $A$ and $B$ are constants. Substituting $y_p(t)$ into the differential equation and solving gives $A=-\frac{1}{2}$ and $B=0$, so that the general solution to $t^2y''-2y=t$ is $$y(t)=C_1t^2+C_2t^{-1}-\frac{1}{2}t.$$
However, if we consider the equation $$t^2y''-2y=t^2$$ instead, then our initial guess for a particular solution, $y_p(t)=At^2+Bt+C$ ($A$, $B$, $C$ constants) "overlaps" with part of our solution to $t^2y''-2y=0$. This suggests that we should look for a particular solution of the form $y_p(t)=At^5+Bt^4+Ct^3$ instead. Substituting this into the ODE to try to solve for $A$, $B$, and $C$ doesn't give anything useful; in fact, through Variation of Parameters, we get a particular solution $y_p(t)=\frac{1}{3}\ln(t)t^2$, which the Method of Undetermined Coefficients has no hope of finding.
I'm not really sure what's going on here. Why does the Method of Undetermined Coefficients fail to give me the correct particular solution in the second case? Is there anything general that can be said here about applying this method in the nonconstant coefficient case?