Pipe nipples come in 1/2" increments, not making life easy.
There is a certain amount of "play" as far as how tight or loose you can tighten these things.
You can also use more thread sealant or less.
Sometimes the valve in the wall can be moved.
In some cases, there is a flange that will slide back and forth too.