Your cancellation is wrong, but somehow you got the right answer for g(x).
[math]g(x) = \dfrac{f(x) - 1}{f(x) + 1} \text { and } f(x) = \dfrac{x- 2017}{x + 2017} \implies\\
g(x) = \left ( \dfrac{x - 2017}{x + 2017} - 1 \right) \div \left ( \dfrac{x - 2017}{x + 2017} + 1 \right) \implies \\
g(x) = \dfrac{x - 2017 - (x + 2017)}{x + 2017} \div \dfrac{x - 2017 + x + 2017}{x + 2017} \implies \\
g(x) = \dfrac{\cancel 2 * (-2017)}{\cancel {x + 2017}} \div \dfrac{\cancel 2 x}{\cancel {x + 2017}} = \dfrac{-2017}{x}.[/math]
Same issue when calculating f(g(x)), but once again you come out right.