Proverbs is a collection of wisdom, and wisdom is from God. The Proverbs 19:17 should have its origin, likely from Leviticus 25:35-38
35 “‘If any of your fellow Israelites become poor and are unable to support themselves among you, help them as you would a foreigner and stranger, so they can continue to live among you.
36 Do not take interest or any profit from them, but fear your God, so that they may continue to live among you.
37 You must not lend them money at interest or sell them food at a profit.
38 I am the Lord your God, who brought you out of Egypt to give you the land of Canaan and to be your God. (Leviticus 25:35-38 NIV)
It is the wisdom perceived by the Israelites that they will receive reward from the Lord when they submitted to the law.
12 May the Lord repay you for what you have done. May you be richly rewarded by the Lord, the God of Israel, under whose wings you have come to take refuge.” (Ruth 2:12 NIV)
Therefore Proverbs 19:17 was a wisdom developed from their understanding of the law. It is not a prophesy.
Matthew 25:40 is within the Olivet Discourse. The Olivet Discourse first describe a scene of the End Times, then Jesus gave three parables which emphasized 'Watchfulness', followed by another parable 'The Sheep and the Goats' as the final judgement, in which the Sheep represent those who would be saved and the Goats being rejected.
It might be interesting that in this parable, both the good and the bad did not know what had they done that led to the King's judgement. The implication of this is being 'Watchfulness' is not something intentional, but natural. In Matthew 25:40, 'the least of these brothers and sisters' are those who need help. The one who is 'Watchful' help them naturally without an intention to get reward from God. There we may see a little contrast between Proverbs 19:17 and Matthew 25:40.
17 Whoever is kind to the poor lends to the Lord,
and he will reward them for what they have done. (Proverbs 19:17 NIV)
40 “The King will reply, ‘Truly I tell you, whatever you did for one of the least of these brothers and sisters of mine, you did for me.’ (Matthew 25:40 NIV)