You can see a man who is listening to something，so it stands for “to listen”.
And when you listen to the answer, it means that you asked something, so 聞 also stands for “to ask”.
Note: You can see the particle before 聞く to judge the meaning.
彼に聞いた：I asked him.
彼から聞いた：I heard from him.