The two anointed ones of Zech c. 4 were the two who were chosen by God to lead the people out of the Babylonian captivity: Joshua, the High Priest and Zerubbabel the leader of the people.
Zech. 4:6-10, (from the KJV)
"6 Then he answered and spake unto me, saying, This is the word of the Lord unto Zerubbabel, saying, Not by might, nor by power, but by my spirit, saith the Lord of hosts.
7 Who art thou, O great mountain? before Zerubbabel thou shalt become a plain: and he shall bring forth the headstone thereof with shoutings, crying, Grace, grace unto it.
8 Moreover the word of the Lord came unto me, saying,
9 The hands of Zerubbabel have laid the foundation of this house; his hands shall also finish it; and thou shalt know that the Lord of hosts hath sent me unto you.
10 For who hath despised the day of small things? for they shall rejoice, and shall see the plummet in the hand of Zerubbabel with those seven; they are the eyes of the Lord, which run to and fro through the whole earth."
It was under the leadership of Joshua and Zerubbabel that the "new heavens and new earth" (Isa. 65:17) - the renewed covenant between God and the people of the second temple, and under which the rebuilding of Jerusalem would be carried out.
The functions of these two anointed of God were the High Priest and the speaker of the word - the shouter, the caller of God's people, the governor of the people. Together they would bring the people into a renewed knowledge of God's word.
Excerpt from Benson's Commentary:
"...As by the candlestick we understand the visible church, particularly that of the Jews at that time, for whose comfort this vision was primarily intended, these sons of oil, that stand by the Lord of the whole earth, are the two great ordinances and offices of the magistracy and ministry, at that time lodged in the hands of those two great and good men, Zerubbabel and Joshua. This prince, this priest, were sons of oil, anointed of God, or endued with the gifts and graces of his Spirit, to qualify them for the work to which they were called. They stood before the Lord of the whole earth, to minister to him, and to receive direction from him; and a great influence they had upon the affairs of the church at that time; for their wisdom, courage, and zeal were continually emptying themselves into the golden bowl, to keep the lamps burning; and when they should be removed, others would be raised up to carry on the same work, and Israel should not be left without prince and priest. " Source: here
The immediate application was to the release from captivity about 538 - 536 BC under Cyrus and Darius the Mede. The fulfilled application, the future meaning was to the High Priest and callers of the word of God under the gospel of Christ.
Christ became our High Priest at His death on the cross. He assigned certain disciples to be His callers and leaders of the people, the messengers of the gospel call of Christ - the apostles and disciples of the new heavens and new earth under the new covenant. The apostles established Christ's church under the new covenant.
The parallel then is Joshua to Christ (Yeshua) and Zerubbabel to the apostles collectively. This then lets us understand Revelation's two olive trees.
Zech 4:14,
" Then said he, These are the two anointed ones, that stand by the Lord of the whole earth." (KJV)
Rev. 11:4,
"These are the two olive trees, and the two candlesticks standing before the God of the earth." (KJV)
The olive trees bear olives which render olive oil. Anointed ones comes from the figurative use of "to the oil", an application of oil to the head, and meant called by, appointed by God for a special office or purpose. Strong's Hebrew 3323 & Strong's Greek 5548.
Luke 4:18-19,
"18 The Spirit of the Lord is upon me, because he hath anointed me to preach the gospel to the poor; he hath sent me to heal the brokenhearted, to preach deliverance to the captives, and recovering of sight to the blind, to set at liberty them that are bruised,
19 To preach the acceptable year of the Lord." (KJV)
Christ was chosen / anointed by God and He became our High Priest (Acts 4:27; Heb. 1:9; 2:17; 3:1).
God chose / anointed the apostles to preach the gospel call, to shout the message of the new covenant to be found in Christ.
2 Cor. 1:21,
"Now he which stablisheth us with you in Christ, and hath anointed us, is God;" (KJV)
So we have the anointing of the High Priest and the anointing of the apostles and leaders who preached the message. And the two witnesses of Rev. 11:3 are defined in Rev. 11:4 as the two olive trees of the new covenant, the new heavens and earth prophesied from old (Isa. 66:22).
That these two olive trees in Revelation were killed after 3-1/2 days, ie. 3-1/2 years reflects the death of Christ after His 3-1/2 year ministry, and the death of the two most prominent leaders / apostles, Peter & Paul.
Many sources place the death of Peter and Paul about mid-66 BC for both of them (See here). That would leave approx. 3-1/2 years before the destruction of Jerusalem in 70 AD for their testimony to continue to cry out.
(Their dead bodies lying in the street of Jerusalem for 3-1/2 years - Rev. 11:8 - was not literal. That was a figurative use meaning their words and their teaching would be reinforced by their deaths, and the gospel would spread because of it for another 3-1/2 years before the city of Jerusalem would be destroyed.)
The parallel must mirror the job function, the calling for which God purposed them, and the ones who reflect the same calling / purpose that had previously occurred under the return of the captivity of Babylon prophesied by Zechariah.