Though it is uncommon, some women ovulate upon sexual arousal. Whether one is menstruating at the point may be pointless. The discharge of an egg means it’s likely for that egg to be fertilized.
As to whether that fertilized egg can attach adequately to the wall of the womb while that wall is being shed is another matter. Thus, the chance of miscarriage could be very high.
Ovulating upon sexual stimulation is one potential reason for why one can become pregnant within two weeks of a miscarriage before the body has had a chance to prepare by going through another cycle. But, the chances that there would be a second miscarriage are quite high, because the wall of the womb hasn’t had a chance to prepare itself to support and hang onto a fertilized egg.