I think they're just being very sloppy with their definitions of the arbitrary functions f and g. In that if you integrate some arbitrary function, then you get some other arbitrary function - and they just used the same name. That's my best guess for what they're doing.
Actually, there's a whole lot about that 'answer' that I don't like. I assume g(x) becoming g(y) is just a mistake. The implicit redefinition of the functions is bogus. And even if they were given new letters, I don't like that the integration constants / functions are introduced before the integral is done. Like, I guess they are a result of integrating the LHS - but then we're implicitly assuming that the other integral will give a constant of zero... To me that doesn't look like good technique. But then again, maybe I've misunderstood the whole thing!
Thx. Any idea where I can learn the right way that is clearer than this sloppy business? I basically threw in the towel of all courses since this hiccup
Sorry, I'm not much help with that kind of advice. My knowledge about it mostly comes from dim memories of my time at university many years ago - with only some very minor bits being kept fresh by regular use.
My only suggestion is that it would be good to use a reputable textbook, so that you can be fairly confident that it is correct and not cutting corners; and then when you practice yourself, you should also make a conscious effort to not cut corners. (It's always tempting to just fudge any changes to arbitrary constants as being unimportant - since they are still arbitrary constants anyway; and mostly it doesn't matter. But that's a bad habit, because sometimes it does matter, and won't notice those times unless you've been paying attention all the time.) I won't try to recommend specific sources though, because I'm very out-of-date with that. I'll just say that published books used by universities are likely to be better than the notes of a private tutor or small online course.