As $A$ is a PID and $M$ is finitely generated, by the structure theorem of finitely generated modules over a PID we have that
$$M\cong A^r\oplus\bigoplus_{i=1}^k A/(p_i^{\alpha_i})$$
for some $r,\alpha_1,\dots,\alpha_k\in \mathbb{Z}$ and some prime elements $p_i\in A$. So you may assume that $M$ is equal to the module in the right.
Now, an injective module must be divisible: for the proof see here and just change $\mathbb{Z}$ by $A$ accordingly (actually, a module is injective iff it is divisible in a PID but this is not used here).
Hence, for each $a\in A$ the map
$$\begin{align*} a\cdot:M&\rightarrow M \\ f&\mapsto a\cdot f \end{align*}$$
is surjective.
This imply that $\alpha_i=0$ for each $i$. Otherwise the map $p_i\cdot$ wouldn't be surjective, because an element in the image of $p_i\cdot$ would always have a $0$ in its $i$-coordinate.
Hence, $M=A^r$. But if the multiplication by $a\cdot$ is surjective then $a$ is invertible (look at the first coordinate of an element in the inverse of $(1,0,\cdots,0)$). Hence every element in $a$ is invertible and $A$ is a field.
So your result is true only if you assume that your ring is not a field as noticed by Severin Schraven in the comments.
As $A$ is a PID and $M$ is finitely generated, by the structure theorem of finitely generated modules over a PID we have that $$M\cong A^r\oplus\bigoplus_{i=1}^k A/(p_i^{\alpha_i})$$ for some $r,\alpha_1,\dots,\alpha_k\in \mathbb{Z}$ and some prime elements $p_i\in A$. So you may assume that $M$ is equal to the module in the right.
Now, an injective module must be divisible: for the proof see here and just change $\mathbb{Z}$ by $A$ accordingly (actually, a module is injective iff it is divisible in a PID but this is not used here).
Hence, for each $a\in A$ the map $$\begin{align*} a\cdot:M&\rightarrow M \\ f&\mapsto a\cdot f \end{align*}$$ is surjective.
This imply that $\alpha_i=0$ for each $i$. Otherwise the map $p_i\cdot$ wouldn't be surjective, because an element in the image of $p_i\cdot$ would always have a $0$ in its $i$-coordinate.
Hence, $M=A^r$. But if the multiplication by $a\cdot$ is surjective then $a$ is invertible (look at the first coordinate of an element in the inverse of $(1,0,\cdots,0)$). Hence every element in $a$ is invertible and $A$ is a field.
So your result is true only if you assume that your ring is not a field as noticed by Severin Schraven in the comments.