[Theorem] Let $M$ be a finitely generated module over a PID $R$. Then $$M \simeq R^d \oplus R/(r_1) \oplus \cdots \oplus R/(r_n)$$ for some $d \geq 0$ and $r_1| \cdots | r_n$.
If we replace the PID by UFD then the theorem fails. I want to find an example showing this. For proving the theorem, we used the fact that for any free $R$-module of finite rank, its submodule is free as well. This is false if $R$ is not a PID. If $R$ is not a PID, then $R$ contains an ideal that is not a free module. For example, the ideal $(x, y)$ in $K[x, y]$, $K$ is a field, is not a free module.
but I couldn't explicitly show that the theorem fails for $K[x, y]$ with $K$ being a field.
I would appreciate any help!