Reall that for ideals in a Dedekind domain, $I\subseteq J\iff J|I$.
The fact that $\pi\in Q$ means that the prime ideal factorization of $(\pi)$ has $Q$ as a factor. The fact that $\pi\notin Q^2$ means that $Q$ occurs only to the first power. Raising $(\pi)$ to the $m$th power you get the ideal $(\pi^m)$, and the factorization will include $Q$ raised exactly to the $m$th power, so $\pi^m\in Q^m$, but $\pi^m\notin Q^{m+1}$.
For a more general ring where this does not hold, consider the simple case of $R=\mathbb{Z}/4\mathbb{Z}$, $Q=(2)$. This is prime and maximal, since $R/Q\cong\mathbb{F}_2$. Then $Q^2=(0)$, $2\in Q\setminus Q^2$, but $2^m\in Q^{m+1}$ for all $m\gt 1$.
Added. Here's an example in a domain: Let $R=F[x^2,x^3]$, considered as a subring of $F[x]$, where $F$ is a field. Let $Q=(x^2,x^3)$, which is prime since $R/Q\cong F$ is a field. Then $x^3\in Q$, and $x^3\notin Q^2 = (x^4,x^5)$. However, $(x^3)^2 = x^6 \in Q^2$ and $x^6\in Q^3=(x^6,x^7)$. (In general, $Q^n = (x^{2n},x^{2n+1})$). Here, $R$ is not integrally closed, since $x$ lies in its field of fractions and satisfies the monic polynomial $t^2-x^2\in R[t]$, but does not lie in $R$.