you have initialize a "varJD" as string.
There you have added the data from your your ms forms.
Now you are trying to replace e.g / etc., from that string.
For this you are adding condition and doing this in three different steps.
My suggestion is:
Try in your first compose without conditions
Replace(msformsdataasString, 'e.g.', 'eg')
Then check the string if it has worked.
If yes, the add in just one compose all your replace inside one another.
Like replace(replace(outputs('ComposeActionName'), 'etc.,', 'etc'), 'e.g.,', 'eg')
See the if your compose is giving you clean string with replaced values.
I am not sure if you have to then initialize the variable at all.
Try using the compose output directly to create word document.
Am wondering why you have to replace etc., or e.g.,? Is it not able to create word document?
--- hope this help you.