Though it can be done by (Lagrange) interpolation, it is just as simple (and more powerful) to use the Chinese Remainder Theorem (CRT), which is $\color{#c00}{\rm very\ easy}$ when the $\color{#c00}{\rm Bezout}$ identity is known
By CRT, $ $ if $\ \color{#c00}{j g} + \color{#c00}{k h} = 1\,$ then $\ \begin{eqnarray}f\equiv a\!\!\!\pmod g\\f\equiv b\!\!\!\pmod h\end{eqnarray}$ $\!\iff\!\!$ $\begin{eqnarray} f&\equiv&\ a\,\color{#c00}{kh}\, +\, b\,\color{#c00}{jg}&&({\rm mod}\ {gh})\\ &\equiv& a+(b\!-\!a)\color{#c00}{jg}&&({\rm mod}\ gh)\end{eqnarray}$
So $\, \underbrace{(x\!-\!1)}_{\large g}-\underbrace{(x\!-\!2)}_{\large h} = 1,$ $\, a,b = f(1),f(2) \Rightarrow f\equiv f(1) +(f(2)\!-\!f(1))(x\!-\!1) \pmod{\!\!(x\!-\!1)(x\!-\!2)}$
Remark $\ $ It was $\,\color{#c00}{\rm easy}$ here since $\,\ g\ {\rm mod}\ h = g - h = (x\!-\!1)-(x\!-\!2) = 1\ $ is invertible in $\,\Bbb Q\,$ hence this immediately yields the Bezout identity, which immediately yields the solution as above. Generally it is just as easy when $\ g\ {\rm mod}\ h\ $ is invertible (which is equivalent to the extended Euclidean algorithm (EEA) terminating in $1$ step, i.e. this is an optimization of the EEA). In particular, the EEA terminates in one step if one of the polynomials is linear.
Since Lagrange interpolation is the special case of CRT when both moduli are linear polynomials, the above optimization always applies.