If one masturbated during the ihram of the Hajj before going to Muzdalifah, one has to pay the Kaffarah and go to Hajj again (repeat it).
Now if you are not sure that this happened during the Ihram, then you can consider your Hajj to be valid. It’s very unlikely that this happened during Ihram because there aren’t really private places in Arafah for one to do that. So your Hajj is valid Insha’Allah and you can get married.