“Ye have heard that it was said by them of old time”.
The “them” was not the Law or Prophets.
“But I say to you”
is Christ correcting the bad teaching of the Pharisees, the leaders of the day.
Christ always taught and supported Yahweh God’s Law, Christ’s Law.