Plumbing in new shower
Warning, U.S. English ahead.  What you purchased would be known as a "nipple", which is a short piece of pipe with male threads on both ends.  You wanted a "coupler" which has female threads on both ends.  I'm not sure if nipple and coupler are used outside of the U.S., but they have specific meanings here.

However, a threaded coupler will normally only work when the piece you are connected can be screwed in (like connecting two straight pipes).  Since the valve you are connecting too looks like it's connected to the shower unit, you're not going to be able to rotate it around in place to screw it into the elbow in the wall.

What you really need is called a "union", and looks like this:



The two ends of the union can be separated and screwed onto the elbow and valve separately.  Then, the large "nut" in the center is used to join the two halves without rotating either end.