How to mitigate an unmounted bathtub faucet from back wall access
Remove the incorrect fitting, replace with a drop-ear elbow, and mount a hunk of wood to mount the drop ear elbow to. This will be awkward and annoying to do (through that hole) but should be possible. You may (or will) need a longer hunk of pipe for the tub spout mount.
Other ways might be possible, but will be kludges, (like the &quot;giant glob of construction adhesive&quot; approach. Easier to do, but a definite kludge.)
Whoever did this install was an idiot. A tub only install needs one drop ear elbow, a tub/shower install needs two, they are made, and this is what they are made for.