I am not too sure I understand the question, all those solutions are correct? Are they not your answers and you are looking for an explanation or what?

you just look at what g does first , then see what f does to that one.

So in the last example you noticed that squaring preserves parity. that is an even squared is even, and an odd squared is odd. Since the second function only depends on whether it is even or odd, the first function might as well just be the identity function and so you are just going to get g again.

On the second to last one, you do them in the opposite order, so for the evens you get -1 and for odds you get 1, but when you square either of these you just get 1, so this composition just always gives you 1.

Hope this helps, but I feel that you are probably asking something else entirely.