Let $A, B$ finite sets, and let $f,g\in A\to B$.
Also, Let the equivalence class:
$$f \sim g \iff \exists h\in Eq(A,A). f=g\circ h $$
Claim: $$f\sim g \iff \forall b\in B. \left| \left\{ a\in A : g(a)=b \right\} \right| = \left| \left\{ a\in A : f(a)=b \right\} \right|$$
The Proof for one side:
Lets assume $f\sim g$ and let $b\in B$.
$$\left| \left\{ a\in A : g(a)=b \right\} \right| = \left| \left\{ h(a)\in A : g(h(a))=b \right\} \right| = \left| \left\{ h(a)\in A : f(a)=b \right\} \right| = \left| \left\{ a\in A : f(a)=b \right\} \right|$$
The change from $a$ to $h(a)$ in the start and the change back from $h(a)$ to $a$ is unclear to me. Why is it true?
Since $h$ and $h^{-1}$ are injective functions, the restriction of $h^{-1}$ to $\{h(a)\in A:f(a)=b\}$ is an injection, and certainly a surjection onto $\{a\in A\mid f(a)=b\}$.
Similarly for the first equality. We use here the fact that $h$ is a bijection.