Shower heads can come in a wide variety of different shapes and sizes including fixed heads, adjustable heads, hose shower heads, and waterfall heads. While every type has their own unique parts, they all connect to the water distribution pipe for the shower in the wall or ceiling. This connection can become loose, leading to not just a loose shower head but also potential leakage.
If the shower head stem itself is loose, this may require securing the stem and pipe with expanding foam. First, pull the trim ring away from the wall using pliers or a screw driver. This should expose the hole in the wall where the shower stem is protruding through. This hole is often cut too big during installation, which can allow the shower stem to move excessively. After putting masking tape around this hole to minimize excess spray foam from sticking to surfaces beyond the hole, apply the expanding foam into the hole all the way around the pipe and protruding slightly outside of the hole. Allow the expanding foam to cure and then trim off any excess foam with scissors or a utility knife. Install the trim ring back into place and check the shower stem to ensure that it is now secured.