Definition: Fulfil - Strong's Gr 4137 "pleroo" means to make full, to complete.
The NASB translation uses it for "accomplish (1), accomplished (1), amply supplied (1), approaching (1), complete (1), completed (3), completing (1), elapsed (1), fill (3), filled (16), fills (1), finished (1), fulfill (20), fulfilled (20), fully carry (1), fully come (1), fully preached (1), increasing (1), made complete (2), made full (5), make...full (1), make...complete (1), passed (2), supply (1)." (Source: Biblehub)
Both usages in John 17:12 and Matt. 26:54 fall under Thayer's Greek Lexicon definition at 2c.
"c. to carry into effect, bring to realization, realize... β. of sayings, promises, prophecies, to bring to pass, ratify, accomplish; ... universally and absolutely, to fulfil, i. e. "to cause God's will (as made known in the law) to be obeyed as it should be, and God's promises (given through the prophets) to receive fulfilment" (Ibid)
Having the definition, we then look at context of the scriptures to determine the full meaning, and not just from the single verse.
"51 And lo, one of those with Jesus, having stretched forth the hand, drew his sword, and having struck the servant of the chief priest, he took off his ear.
52 Then saith Jesus to him, `Turn back thy sword to its place; for all who did take the sword, by the sword shall perish;
53 dost thou think that I am not able now to call upon my Father, and He will place beside me more than twelve legions of messengers?
54 how then may the Writings be fulfilled, that thus it behoveth to happen?'
55 In that hour said Jesus to the multitudes, `As against a robber ye did come forth, with swords and sticks, to take me! daily with you I was sitting teaching in the temple, and ye did not lay hold on me;
56 but all this hath come to pass, that the Writings of the prophets may be fulfilled;' then all the disciples, having left him, fled." (YLT)
Jesus was clearly stating that what was happening was not by the will of man, but the predetermined will of God for His plan of salvation to be accomplished (Acts 2:23). He stated that He could have called the heavenly messengers to defend Him. He obviously did not need the defense of the disciple's sword.
The context then is that even though He had the power to change it, He was not going to. He did not want to prevent it as He went to the cross willingly for our sakes (John 10:17-18; Eph. 5:2; 2 Cor 8:9)).
Reading the scriptures from the human emotional perspective is sometimes a disadvantage. Our feelings become caught up in our fears of the physical death Jesus was going to endure, our empathy for the horror of having nails driven through His feet and hands, of a slow suffocating death while hanging on that cross.
Jesus' prayer in Matt. 26:39 for the cup to pass from Him was not caused by the fear of physical death, but the shame of having all of the sins of all of mankind laid upon Him. He despised that shame because for a few moments it was going to separate Him from the Father (Matt. 27:46).
"looking to Jesus the pioneer and perfecter of our faith, who for the joy that was set before him endured the cross, despising the shame, ..." (Heb. 12:2, RSV)
The context of Jesus' prayer for His disciples in John 17, beginning with vs. 9:
"9 `I ask in regard to them; not in regard to the world do I ask, but in regard to those whom Thou hast given to me, because Thine they are,
10 and all mine are Thine, and Thine [are] mine, and I have been glorified in them;
11 and no more am I in the world, and these are in the world, and I come unto Thee. Holy Father, keep them in Thy name, whom Thou hast given to me, that they may be one as we;
12 when I was with them in the world, I was keeping them in Thy name; those whom Thou hast given to me I did guard, and none of them was destroyed, except the son of the destruction, that the Writing may be fulfilled.
13 `And now unto Thee I come, and these things I speak in the world, that they may have my joy fulfilled in themselves;" (YLT)
And further, in vs. 18, "as Thou did send me to the world..."
The mention of Judas in vs. 12 is a parenthetical qualifier. Ellicott's commentary here is helpful:
"The term, “son of perdition,” is a well-known Hebrew idiom, by which the lack of qualitative adjectives is supplied by the use of the abstract substantives, which express that quality. A disobedient child is, e.g., “a son of disobedience;” other common instances are “children of light,” “children of darkness.” A “son of perdition” is one in whose nature there is the quality expressed by “perdition.” The phrase is used in Isaiah 57:4 to express the apostacy of the Israelites (in English version, “children of transgression”). It occurs once again in 2Thessalonians 2:3, of the “man of sin.” (Comp. Notes there.) It is used, in the Gospel of Nicodemus, of the devil. In the present passage it is difficult to express the meaning in English, because we have no verb of the same root as the abstract substantive “perdition,” and no abstract substantive of the same root as the verb “perish.” No exact translation can therefore give in English the point of our Lord’s words, “And none of them perished except him whose nature it was to perish.” " (Source: Biblehub)
The verse is not about Judas specifically, but about the keeping of those who believed. Keeping them, preserving and guarding over them. (Strong's Gr. 5083, tereo)
Jesus came to do the Father's will (John 6:38). He always sought the Father's will (John 4:34; 8:30). He was fulfilling, accomplishing, completing - keeping - the prophecies that were told in times past by the messengers God sent, including those of His own - the Messenger (Angel) of the Lord, the Word that was with God (John 1:1).
Not fatalism, but promise. He was keeping the promises of God; the promises to Abraham that through His seed (Isaac) all nations should be blessed (Gen. 12:2-3; John 8:56); the promises for His children for both obedience and disobedience (Deu. 30:15-20); His promise of salvation for all who will believe (Rom. 1:16-17).
And He did so by His actions to accomplish, complete and fulfill those promises. The best sense of the use of the word in these passages is accomplishing and keeping the promises of God that had been written before.