I asked this question in MathStackExchange, but I didn't receive any answer.

Let $K/\mathbb{Q}$ be a Galois extension of degree $n$, and denote its ring of integers by $\mathcal{O}_K$. Let $\mathfrak{p}$ be an arbitrary prime ideal of $\mathcal{O}_K$, which is unramified over $\mathbb{Z}$, and prime to $n!$. We will denote the residue field of $\mathfrak{p}$ by $\kappa(\mathfrak{p})$, its characteristic by $p$, and its residue degree by $f$. Let $x \in \mathcal{O}_K$, and let $\bar{x}$ be its image in $\kappa(\mathfrak{p})$, and assume that $P \in \mathbb{Z}[X]$ is a monic minimal polynomial of $\bar{x}$, such that $P(x) \in \mathfrak{p} \backslash \mathfrak{p}^2$, and $\deg(P)=f$.

(Q): Show that $\mathcal{O}_K/\mathfrak{p}^2$ is generated by the image of $x$ over $\mathbb{Z}/p^2\mathbb{Z}$.

My attempts: Since $P$ has minimal degree among the polynomials which are vanishing $x$ module $\mathfrak{p}$, it should be irreducible over the field $\mathbb{Z}/p\mathbb{Z}$.
Therefore $1, x, \cdots, x^{f-1}$ are linearly independent over $\mathbb{Z}/p$.
Also, notice that $$\dfrac{\dfrac{\mathbb{Z}}{p\mathbb{Z}}}{P(X)} \equiv \dfrac{\mathbb{Z}}{p\mathbb{Z}} \oplus x \dfrac{\mathbb{Z}}{p\mathbb{Z}} \oplus \cdots \oplus x^{f-1}\dfrac{\mathbb{Z}}{p\mathbb{Z}}$$
is a field between $\dfrac{\mathbb{Z}}{p\mathbb{Z}}$ and $\dfrac{\mathcal{O}_K}{\mathfrak{p}}$, with $\dfrac{\mathbb{Z}}{p\mathbb{Z}}$-degree equal to $f=[\dfrac{\mathcal{O}_K}{\mathfrak{p}}:\dfrac{\mathbb{Z}}{p\mathbb{Z}}]$, so it should equal to $\dfrac{\mathcal{O}_K}{\mathfrak{p}}$. So we can conclude that $\dfrac{\mathcal{O}_K}{\mathfrak{p}}$ is generated by the image of $x$ over $\dfrac{\mathbb{Z}}{p\mathbb{Z}}$. (My proof of this fact may contain extra details; if so, please let me know). **But** I don't have any idea why $\mathcal{O}_K/\mathfrak{p}^2$ is generated by the image of $x$ over $\mathbb{Z}/p^2\mathbb{Z}$?

I'm looking to figure out how, in this case, "the assumption $P(x) \in \mathfrak{p} \backslash \mathfrak{p}^2$" helps me solve the problem. I have this issue with similar problems; for instance, I had trouble dealing with

exercises 19-22 from chapter 4 of Marcus's Number Fields. (In these exercises I had to deal with "the assumption $\pi \in Q \backslash Q^2$", finally I solved them after a long hard try and search). Also, I tried to look for some versions of Nakayama's lemma, but I have not succeeded.