Your proof only works if the projective dimensions of $M$ as an $R$-module and as an $R/I$-module are finite. Indeed, finite projective dimension is a hypothesis for the Auslander-Buchsbaum formula, and you used the AB-formula for $M$ as an $R/I$-module in your argument.
In the case of your counter-example, the projective dimension of $R/I$ M$is$\infty$. E.g., is if$R=\mathbb{C}[x]$(or its localization at$0$if you like),$a=x$, then you have the resolution: $$\ldots\to\mathbb{C}[x]/x^2\overset{\cdot x}\to\mathbb{C}[x]/x^2\overset{\cdot x}{\to}\mathbb{C}[x]/x^2\to 0\to \ldots$$ of the module$\mathbb{C}$. Using this to compute$\operatorname{Ext}^{\cdot}_{\mathbb{C}[x]/x^2}(\mathbb{C},\mathbb{C})$, one sees that $$\operatorname{Ext}^{i}_{\mathbb{C}[x]/x^2}(\mathbb{C},\mathbb{C})=\mathbb{C}$$ for all$i\geq{0}$. In particular, the projective dimension is infinite. In this case, your module is$\mathbb{C}\oplus\mathbb{C}[x]/x^2$, which by the above has infinite projective dimension. Therefore, your equality is$\infty+1=\infty$, which is known from antiquity (Zeno et al). 1 The projective dimension of$R/I$is$\infty$. E.g., is$R=\mathbb{C}[x]$(or its localization at$0$if you like),$a=x$, then you have the resolution: $$\ldots\to\mathbb{C}[x]/x^2\overset{\cdot x}\to\mathbb{C}[x]/x^2\overset{\cdot x}{\to}\mathbb{C}[x]/x^2\to 0\to \ldots$$ of the module$\mathbb{C}$. Using this to compute$\operatorname{Ext}^{\cdot}_{\mathbb{C}[x]/x^2}(\mathbb{C},\mathbb{C})$, one sees that $$\operatorname{Ext}^{i}_{\mathbb{C}[x]/x^2}(\mathbb{C},\mathbb{C})=\mathbb{C}$$ for all$i\geq{0}$. In particular, the projective dimension is infinite. In this case, your module is$\mathbb{C}\oplus\mathbb{C}[x]/x^2$, which by the above has infinite projective dimension. Therefore, your equality is$\infty+1=\infty\$, which is known from antiquity (Zeno et al).