DataValue of Rail ignored when using /setblock /clone /fill
Rails placed using the setblock command will only be oriented by the specified dataValue if there is already a rail at the specified coordinates. Otherwise, it will orient the rail such that it connects to adjacent rails, or if there are none, it will always place the north_south variant.
To reproduce, use this command in an open space:
/setblock ~1 ~ ~ minecraft:rail 9 replace
This will place a straight section of rail north/south. Without moving, use the command again, and the rail will change into the desired type: a curved section facing north/east.
If positioned so that the rail will be placed next to another rail, both rails will change shape in order to connect.