Thanks for using healthcare magic.
I have gone through your available history.
You should rule out the urine infection by doing urine routine and microscopic examination.
It is possible to have occasional weak erection during sex.
If it happens occasionally, you should not worry about that.
If it is persistent, you should consult sexologist/psychiatrist
for detailed evaluation and treatment.
You might be benefited by master & johnson technique.