This idea will be better than nothing, and it may not stop it all, and if you have large tile rather than small tile, there will be less chance of damaging the wall.
Since the water supply lines are PEX or something similar, you might could use those too. But to get at what the fix is, push the copper pipe that is at the top that goes to the shower head, the plastic (PEX) lines should flex enough to allow this to happen. Push it back the 1/2" you need to get the plate flush to the wall. Measure the space between the pipe and the wall board (tile backer) and cut a block that will fit the space. This is also considering that the pipe moves easily. If it takes too much pressure to push the pipe back, the block may crack the wall, the tile or both, from the backside by the pipe pushing back. The longer the block is at the correct thickness to hold the pipe the chance of it cracking the wall is lessened. The larger tile I referred to at the beginning will help too.
If it is easy to push back, the cover plate is made to still fit, if the valve is pushed back a little extra. Once you get the block to fit well, use a painters caulk or something that will stick it to the wall so it does not fall out over the long haul.
Your idea will work too about gluing the 2X to the wall, but it usually takes a piece of 3/4" to 1" material. You could use shims to get it the rest of the way once you get the 3/4" material in.