Our human language is limited. A word usually has more than one meaning, so we must be careful not to read the same meaning into a different context where it doesn’t apply.
I don’t see where Jesus referred to faith as a work of the law, but He said that faithfulness was a matter of the law–in other words, the Pharisees were following the “letter of the law,” but ignoring the reason for it, the spirit of the law: to know, love and serve God.
If you read further in John 6, you may see that Jesus was referring to belief in Him both as God’s Son, and as the Bread of Life (the Eucharist). If we believe in Him, and we believe what he says–that we must eat His Flesh–then what must happen? Jesus was not just speaking about the intellectual belief that He
exists (He’s standing right in front of them, after all), but faith about who He is and what that means for them and us (eating His Flesh).
In other words, there is faith that refers to an intellectual belief only, and then there is another meaning of faith, which is formed in charity and includes hope, love, and trust in God.
Perhaps this article will help:
ewtn.com/library/ANSWERS/SOLAFIDE.htm
P.S. Paul was referring to the Jewish Law, saying that Gentiles do not need to follow the Jewish Law in order to follow Christ.