So, let me get this straight. Joseph notices that Mary is pregnant. Joseph confronts Mary about it. And Mary replies: err, hmm, I know, the angel of the Lord came down and impregnated me. We’re going to have the child of God. And Joseph is like: okay, cool.
Mary may or may not have been a virgin in the original text. There’s a translation discrepancy. This thread on Reddit goes more in depth with it than most people probably would be interested in.
https://www.reddit.com/r/AcademicBiblical/comments/utqtov/is_virgin_definitely_a_mistranslation/
tl;dr : the word translated to young woman, and that was later changed by translators to virgin.