Let's try a somewhat more example-driven answer.
Take an electron in the state $\psi\left(x\right)=\frac{1}{\sqrt{2\pi\hbar}}e^{i\frac{p}{\hbar}x}$ (assume $p>0$). As you said, the momentum operator $\hat{p}=-i\hbar\frac{\partial}{\partial x}$ retrieves the momentum by a simple relation
$$\hat{p}\psi\left(x\right)=p\psi\left(x\right)$$
So this is an electron moving to the right with momentum $p$. All good.
Now take a look at another perfectly valid state, $\psi\left(x\right)=\frac{1}{\sqrt{\pi\hbar}}\cos\left(\frac{p}{\hbar}x\right)$. Applying the momentum operator this time gives
$$\hat{p}\psi\left(x\right)=-i\hbar\frac{\partial}{\partial x}\frac{1}{\sqrt{\pi\hbar}}\cos\left(\frac{p}{\hbar}x\right)=ip\frac{1}{\sqrt{\pi\hbar}}\sin\left(\frac{p}{\hbar}x\right)$$
Yikes. This is in no way $\left({\rm some\:constant}\right)\cdot\psi\left(x\right)$. So we can ask ourselves: what is the momentum of this state? To answer this question you need to understand that we are not reading the information correctly, or maybe even expecting something wrong. Let us rewrite our state differently
$$\psi\left(x\right)=\frac{1}{\sqrt{\pi\hbar}}\cos\left(\frac{p}{\hbar}x\right)=\frac{1}{\sqrt{2}}\color{red}{\frac{1}{\sqrt{2\pi\hbar}}e^{i\frac{p}{\hbar}x}}+\frac{1}{\sqrt{2}}\color{blue}{\frac{1}{\sqrt{2\pi\hbar}}e^{-i\frac{p}{\hbar}x}}$$
Now look what happened. This state has in fact two components - one with momentum $\color{red}{p}$ and one with momentum $\color{blue}{-p}$. It is as simple as that, our state simply doesn't have a single value of momentum, but rather two. An electron in this state moves to the right and to the left at the same time.
So $\hat{p}$ knows how to retrieve the momentum of its eigenstates. Want to find to momentum of a general $\psi$? Just write it as a sum of eigenstates of $\hat{p}$. Let's call them $\psi_{p}$, and write
$$\psi=\sum_{p}c_{p}\psi_{p}$$
Each $\psi_{p}$ have definite momentum $p$, and your $\psi$ has a component of fraction $\left|c_{p}\right|^{2}$ with momentum $p$.