First, the text eliminates the possibility that Joseph’s seed contributed to the conception because it said Mary was found pregnant (lit., “having in her womb”) while she and Joseph were betrothed and before she and Joseph came together (i.e., had intercourse).
Notice the phrase at the end: «ἐκ πνεύματος ἁγίου». The text does not use the prepositions διὰ or ὑπὸ to suggest that the Holy Spirit functioned as an instrumental agent in the conception.1 Rather, it uses ἐκ. For example, in Rom. 9:10, the apostle Paul wrote the following:2
10 and not only this, even Rebecca, having conception of one, our father Isaac,
Ιʹ οὐ μόνον δέ ἀλλὰ καὶ Ῥεβέκκα ἐξ ἑνὸς κοίτην ἔχουσα Ἰσαὰκ τοῦ πατρὸς ἡμῶν·
In Rom. 9:10, ἐξ is referring to the father of the offspring (twins) conceived in Rebecca. Likewise, in Matt. 1:18, ἐξ is referring to the father of the offspring conceived in Mary. For that reason, the child was called the son of God.3
Footnotes
1 As in the case of God enabling an infertile woman such as the 90-year old Sarah to conceive Isaac with Abraham. Gen. 17:17 cf. Gen. 21:2.
2 Rom. 9:10 has the word κοίτην, literally “bed.” Most translators agree that it is understood as “intercourse,” but not only that. As a metonymy of the cause for the effect, the author likely means seed or conception. BDAG, κοίτη, 2., b., has a remark on Rom. 9:10: κοίτην ἔχειν ἐξ ἑνός conceive children by one man Ro 9:10. Likewise, in the LXX of Num. 5:20, it has «καὶ ἔδωκέν τις τὴν κοίτην αὐτοῦ ἐν σοὶ»—“and if some man gave you his bed in you.” (Here, κοίτην clearly refers to seed.)
3 cf. Luke 1:35