Let $a_n$ be the number of arrangements in which the first and last basket have different colours, and $b_n$ the number of arrangements in which they have the same colour, where in either case adjacent baskets can't have the same colour. Then by adding an admissible basket at the end of such an arrangement we obtain the recurrence
$$
\begin{align}
a_{n+1}&=(r-2)a_n+(r-1)b_n\;,\\
b_{n+1}&=a_n\;,
\end{align}
$$
and substituting the second equation into the first yields
$$
a_{n+1}=(r-2)a_n+(r-1)a_{n-1}\;.
$$
The characteristic equation is
$$
\lambda^2-(r-2)\lambda-(r-1)=0\;,
$$
with solutions $\lambda=-1$ and $\lambda=r-1$. Thus we have
$$
a_n=c_1(-1)^n+c_2(r-1)^n\;,
$$
and the initial conditions $a_1=0$ and $a_2=r(r-1)$ yield
$$
-c_1+c_2(r-1)=0\;,\\
c_1+c_2(r-1)^2=r(r-1)
$$
with solution $c_1=r-1$, $c_2=1$. The desired number of arrangements is therefore
$$
a_n=(-1)^n(r-1)+(r-1)^n\;.
$$
To get the number of arrangements that use all $r$ colours, you can use inclusion/exclusion:
$$
\sum_{k=0}^r(-1)^{r-k}\binom rk\left((-1)^n(k-1)+(k-1)^n\right)\;,
$$
and the sum over the first term vanishes, leaving
$$
\sum_{k=0}^r(-1)^{r-k}\binom rk(k-1)^n\;.
$$
Best Answer
If you insist on using the inclusion exclusion principle you can argue as follows:
Denote the vertical edges of the room by $e_i$ $(1\leq i\leq4)$. There are $3^4$ colorings with no restrictions. There are ${4\choose1}\cdot 3^3$ colorings with at least one illegal edge $e_i$, ${4\choose2}\cdot 3^2$ colorings with at least two illegal edges $e_i$, $e_j$, $i<j$, then ${4\choose3}\cdot3^1$ colorings with at least three illegal edges $e_i$, $e_j$, $e_k$, $i<j<k$, and finally ${4\choose4}\cdot 3$ colorings with all four edges certified illegal. The total number of legal colorings then comes to $$3^4-{4\choose1}\cdot 3^3+{4\choose2}\cdot 3^2-{4\choose3}\cdot3^1+{4\choose4}\cdot 3=18\ .$$