Let $g:B \to C$ and $h: B \to C$ be functions, so that $g \circ f = h\circ f$ for all $f: A \to B$. To prove that $g=h$. The way I proceeded to prove is as follows:
Since $g\circ f = h\circ f$ for all $f$, I thought it was safe to assume that $f$ is surjective, so that $B \subset ranf$. Hence:
$(x,y) \in g \implies x \in domg \implies x \in B \implies x\in ranf \implies \exists z(z,x) \in f \implies \exists z (z,x) \in f $and $(x,y) \in g \implies \exists z(z,y) \in g\circ f \implies \exists z(z,y) \in h\circ f \implies \exists v, \exists z (z,v) \in f $and $(v,y) \in h \implies \exists z, \exists v\in f $ and $(z,x) \in f \implies v=x \implies (x,y) \in h$.
The second half of the proof is completely analogous to the first half, so I don't think it's required to write it down. However, did I prove it correctly? Was there any flaw or falt in my reasoning? I am asking for I require constant confirmation from the more professional since I am only new to set theory. Thank you in advance.
Your proof cannot work, because you assume that there exists $f : A\to B$ that is surjective. Counter-example: there is no surjection from $\mathbb{N}$ to $\mathbb{R}$.
Second point, there is something missing in your statement : the initial quantifier. Indeed, the goal is to prove $$\forall x\in B\,,g(x)=h(x)$$ or, as you wrote using "formal ZF function definition", $$\forall (x,y)\in B\times C\,,(x,y)\in g\Leftrightarrow (x,y)\in h$$
You must begin with this "forall" quantifier.
However, you can process as this (supposing neither $A,B,C$ are empty) :