There are some standard elementary tricks for such functional equations. Mostly just experience and intution and trying obvious things. For example,
in equation (2) if $\,y=0\,$ then $\,a g(0) = g(0)\,$ which forces $\,a=1\,$ if $\,g(0)\ne 0\,$ and $\,g(y)+y = g(y)\,$ which can't be true for $\,y\ne 0\,$, and so define $\,f(x) := g(x)/x\,$ if $\,x\ne0.\,$ But now assuming $\,ay\ne 0\,$ we get $\,1+f(y) = f(ay)\,$ which reminds us of logarithms. So $\,f(y) = \log_a(y) + b\,$ is one possible solution depending on $\,b.\,$ Uniqueness usually comes only if the functions are "nice" enough, for example, continuous, otherwise there are "bad" counterexamples. In our particular case of $\,f(y)\,$ the $\,b\,$ is arbitrary and hence not unique, but since $\,f(1)=b\,$ even if the value of $\,f(1)\,$ were given, then there would still be "bad" counterexamples.