The exercise asks the following: Let $A$ and $B$ be $L$-structures, $X$ a subset of Dom($A$) and $f: \langle X \rangle_{A} \to B$ and $g: \langle X \rangle_{A} \to B$ be homomorphisms. Show that if $f\mid X = g \mid X$ then $f = g$.
My only thoughts are that $f(x^A)=x^B=g(x^A)$ by the definition of a HM, (I know that doesn't mean $f=g$) and that fg and gf are both HMs. I'm really confused at how to use that $f\mid X=g\mid X$. I know that $\langle X \rangle_A$ is a substructure of $A$, but this only means that $f^{\langle X \rangle_A}=f^{A}\mid dom(\langle X \rangle_A)^n$ right? What do I seem to be missing/not understanding? Any help or suggestions are much appreciated (please no solutions).
As requested, not a solution, but here are some hints/ideas to think about to piece together a solution.
First, let's make sure we understand the problem properly. The notation $f(x^A) = x^B = g(x^B)$ does not really make sense, because $x$ is just an element in $X$ and not a symbol in the language, so there is no interpretation of $x$ in $A$ or $B$ or so. If $x \in X$ then $f(x)$ and $g(x)$ are simply elements in $\operatorname{Dom}(B)$. What $f|_X = g|_X$ is saying is that $f(x) = g(x)$ for all $x \in X$. This has nothing to do with being a homomorphism, at this point we are just talking about a function between sets.
Now, as you probably understood, $\langle X \rangle_A$ can contain more than just $X$. For example, if $A$ is the structure $(\mathbb{N}; +)$ that has domain natural numbers and a binary operation $+$. Then $\langle \{0, 1\} \rangle_A$ must contain all natural numbers, as it must contain $1+1$, $1+1+1$, etc. Thus $\langle \{0, 1\} \rangle_A = A$. In general, $\langle X \rangle_A$ must at least be closed under all function and constant symbols in the language of $A$. Exercise: prove that closing $X$ under all function and constant symbols yields (the domain of) $\langle X \rangle_A$. I have not made it very precise what I mean by "closing under all function and constant symbols", but I'll leave finding a precise formulation for that to you as well (the example should help you think about what it should mean).
Now that we (kind of) know what $\langle X \rangle_A$ looks like, we can complete the exercise by using that $f$ and $g$ are homomorphisms. Back to my example of $A = (\mathbb{N}; +)$. Suppose that $f: \langle \{0, 1\} \rangle_A \to B$ is a homomorphism (remember, $\langle \{0, 1\} \rangle_A = A$), where $B$ is some other structure with a binary relation symbol (if you want something concrete to think about, take for example $B = (\mathbb{R}; +)$). Let $b_0, b_1 \in \operatorname{Dom}(B)$ such that $f(0) = b_0$ and $f(1) = b_1$. Then what is $f(2)$ in terms of $b_0$ and $b_1$? And $f(3)$? If $g: \langle \{0, 1\} \rangle_A \to B$ is a homomorphism such that $g(0) = b_0$ and $g(1) = b_1$ can there then be some $x \in \mathbb{N}$ such that $g(x) \neq f(x)$? Assuming you have found the correct answers to these questions, try to push these ideas through to the general case for the exercise.