In these passages the account of Jesus healing a man who was blind from birth. After being healed the man was criticized by the Pharisees for believing in Jesus, that Jesus was the Christ. The Pharisees were blind spiritually and rejected Jesus. They focused on the legalism of their religion. They maintained that Jesus was not from God because He healed the man on a Sabbath day.
When the Pharisees questioned the man, he said something important. He said to the Pharisees, “God does not hear sinners; but if anyone is God-fearing, and does his will, He hears him.”
I do not think that God hears all prayers. Religious people pray, but not necessarily in ‘Spirit and in Truth.’ Some pray by rote and not from their heart.
God will hear the prayers of the righteous, those who walk rightly before Him. The Bible says, “The prayers of a righteous man avails much.”