The Z axis of the cam points away from the cam. If the Z axis pointed inward, you would open the properties dialog box for the 2D contact joint and invert the normal direction of the Z axis for the cam. Likewise for the valve, if the Z axis pointed inward, you would invert the Z axis.
The fact that the Z axis points away from the cam indicates that it is the outer surface of the part rather than the inner surface of a hole or cut. In this case, the Z axis must always point out away from the part material rather than into the part material.