Shower arm - thread sticking out of wall is too long
The nipple going to the shower head is too long. A simple fix is to measure the gap, then remove the nipple and deduct the gap distance and purchase a new one. I would recommend a brass nipple because there will be less issues with dissimilar metals that can eat away at the pipe or shower fixture. 

If you cannot find the right length a new nipple can be made using 1/2" copper and 2 male threads. This will require some cutting and soldering but the exact length can be made if needed. Get some Teflon pipe tape or liquid sealant and coat the new nipple threads. I install the pipe into the wall first and snug it down then the shower head assembly. Use caution when tightening because you don't know how the elbow or 90 in the wall is anchored.