"the screenshot shows several instances where the given code was duplicated. Is there a setting I need to turn on/off in Firefox to prevent this?"
the editor that freecodecamp uses (Monaco editor) is not optimised for a touch device
you can try with a different browser but it may not work
it is recommended to use a desktop device
you can try this