Alternative proof for Structure theorem for finitely generated modules over a principal ideal domain

I'm thinking of an alternative proof for Structure theorem for finitely generated modules over a principal ideal domain (also called Fundamental theorem of finitely generated modules over a PID in some books), but I don't know where I am wrong.

Statement: let $$R$$ be a PID, $$M$$ be a finitely generated $$R$$ module, then $$M \cong \prod_{i=1}^n R/Ra_i$$, where $$n>0$$ and each $$a_i \in R$$

So here's my idea: Since a finitely generated $$R$$-module $$M$$ is a quotient of a finite free $$R$$-module $$R^n$$, we may write $$M$$ as $$R^n/N$$, where $$N$$ is a submodule of $$R^n$$;

As $$R^n$$ is a finite direct sum it also has a product ring structure, hence $$N$$ can also be viewed as an ideal over the product ring $$R^n$$, while we know that every ideal over $$R^n$$ can be written as $$\prod_{i=1}^{n} I_i$$, where each $$I_i$$ is an ideal of $$R$$, $$M$$ is isomorphic to $$R^n/\prod_{i=1}^nI_i$$;

With some results from ring theory, we may prove that $$M\cong R^n/\prod_{i=1}^nI_i \cong \prod_{i=1}^n R/I_i \cong \prod_{i=1}^n R/(a_i)$$. The last equivalence is true since $$R$$ is a PID. As $$(a_i) = Ra_i$$, the proof is finished.

I searched for this approach but haven't seen any book or references using it, so I guess there's probably something wrong with the proof. So could anyone tell me where the problem is?

$$N$$ is a $$R$$-submodule of $$R^n$$, but not necessarily a $$R^n$$-submodule, i.e. an ideal. Consider for instance $$n=2$$ and $$N=\langle (1,1)\rangle$$, this is not closed under scalar multiplication from $$R^2$$.