There is no contradiction. The answer lies in when the two books were written. The book of Hebrews was written approx. AD 65-66, while Matthew was written approx late 50's to early 60's AD, and recorded what Jesus had told His disciples before His crucifixion about 30 years earlier around 30-31 AD. (1)
The author of Hebrews was speaking directly to his audience in the then current time frame of AD 65-66, and so indicated that the time of Jesus' return was soon, and that Christ would not tarry.
"For yet a little while, and he that shall come will come, and will not tarry."
(Heb. 10:37, KJV)
Christ's statement to His disciples of His return in glory and judgment in Matt. 25 was tied to and still part of the Olivet Discourse for the destruction of Jerusalem (Matt. 24). The destruction of Jerusalem in AD 70 was yet some 40 more years from His crucifixion. That was still many years away from the time Christ spoke this prophesy, so it was going to be a long time in man's expectations to wait.
While the book of Hebrews places that "little while" about 4-5 years before the destruction of Jerusalem. The author of the book of Hebrews was inspired by the Holy Spirit, and would only speak the truth. To say otherwise is to call the Holy Spirit a liar or deceiver, and that is blasphemy.
There is no discrepancy between these verses when we put the time the authors spoke into context of those events in the 1st century AD. Christ's second appearance in that generation was His judgment / coming against those wicked, rebellious people in Jerusalem in AD 70.
"So Christ was once offered to bear the sins of many; and unto them that look for him shall he appear the second time without sin unto salvation." (Heb. 9:28, KJV)
"so also the Christ, once having been offered to bear the sins of many, a second time, apart from a sin-offering, shall appear, to those waiting for him -- to salvation!" (Heb. 9:28, YLT)
His second appearance was to be "apart from sin", or not for the purpose of salvation from sin, but for a different salvation; that is the deliverance from their tribulation under the persecution of the Sanhedrin and from Rome.
The word translated as "salvation" in Heb. 9:28 is Strong's Gr. 4991, soterian. (2) The first definition is deliverance. Christ's death on the cross provided the method for our salvation from sin if we will answer His call to be immersed into His sacrifice. But, His second appearance was for judgment, and to deliver His people from the persecutions of their enemies. And, that deliverance came with the destruction of those tyrants whose power was shattered when that temple in Jerusalem fell.
"6 and he saith to the one clothed in linen, who [is] upon the waters of the flood, `Till when [is] the end of these wonders?'
7 And I hear the one clothed in linen, who [is] upon the waters of the flood, and he doth lift up his right hand and his left unto the heavens, and sweareth by Him who is living to the age, that, `After a time, times, and a half, and at the completion of the scattering of the power of the holy people, finished are all these.'" (Dan. 12:6-7, YLT)
Christ's second appearance / coming was at hand, and imminent when Hebrews and the book of Revelation was written. We are not waiting for Him to destroy that temple any longer. We live now under His everlasting kingdom, in the final Feast of Tabernacles, tabernacling with Him (Rev. 21:3). He reigns now at the right hand of the Father, and has ever since His ascension (Acts. 1:9).
Notes:
Date of Hebrews - DatingTheNewTestament
Date of Matthew - DatingTheNewTestament
Strong's Gr. 4991, soterian - Biblehub