Does Leviticus 18:17 forbid all sexual relations with a mother if you had sex with her daughter or vice versa if you are not married to the one you had sexual relations with? I know the apostle Paul talked about when people have sex that they become one flesh but that is only during the sex.
That verse in Leviticus only states that if a woman is taken as a wife, then sexual relations with her daughters / granddaughters are forbidden. So if there's no marriage, sex isn't even considered.
Also, your claim
when people have sex that they become one flesh but that is only during the sex
... is wrong. That "become one flesh" comes from Genesis 2:24
24 For this reason a man shall leave his father and his mother, and be joined to his wife; and they shall become one flesh.
In 1 Corinthians 7:2
But because of sexual immoralities, each man is to have his own wife, and each woman is to have her own husband.
The word here for "sexual immoralities" comes from the word porneia and addresses any illicit sexual behavior, like the one you've just described. God designed sex as something good but in the confines of marriage... Anything else apart from that is sexual immorality.
In ancient times a man’s primary purpose for sexual relations was to have children and build nations.
Leviticus 18:17 (NLT) “Do not have sexual relations with both a woman and her daughter. And do not take her granddaughter, whether her son’s daughter or her daughter’s daughter, and have sexual relations with her. They are close relatives, and this would be a wicked act.
The purpose of the passage it to discourage men from creating illegitimate children and nations, by impregnating a woman and her daughter, or by impregnating a woman and her granddaughter.