Here is an answer via the Argument Principle. Consider analytic
$h:D\longrightarrow \mathbb C$ given by $h(z)=g^{-1}\big(f(z)\big) - z$
If an analytic map from $D\to D$, like $g^{-1}\circ f$, has (at least) two distinct fixed points then it is the identity map, ref e.g. Schwarz's Lemma, fixed points question. This is equivalent to saying for distinct $w,w'\in D$ that $h(w)=0=h(w')\implies h=0$. And in this case we can almost 'eyeball' this to be true since $h(z_0)=0=h'(z_0)$ would seem to imply a winding number of at least $2$ around $z_0$.
To formalize this, suppose for contradiction that $h\neq 0$.
Then $h(z_0)=0$ and $h'(z_0)=0$; by principle of isolated zeros for small enough $r\gt0$ we know $h(z)\neq 0$ for $z \in\overline B(z_0,r) -\big\{z_0\big\} \subseteq D$. With $\gamma(t) := z_0 +r\cdot\exp\big(2\pi i\cdot t\big)$ for $t\in[0,1]$, we have winding number $n\big(h\circ \gamma,0\big)=m\geq 2$ by the Argument Principle.
Define $h_k(z) := \frac{1}{k}z_0 + \frac{k-1}{k}g^{-1}\big(f(z)\big) – z $, checking
(a) $h_k\big(z_0\big)= \frac{1}{k}z_0 + \frac{k-1}{k}\cdot z_0 – z_0 = 0$ and
(b) $h_k'\big(z_0\big)= 0+\frac{k-1}{k}\cdot 1 – 1 = -\frac{1}{k}\neq 0$
So $z_0$ is a simple zero of $h_k$ for all $k\in \mathbb N$. However $h_k$ converges uniformly to $h$ in $\overline B(z_0,r)$ hence it has $m$ zeros in $B(z_0,r)$ for all $k$ large enough [Hurwitz]-- i.e. $h_k(z)$ has at least 2 distinct zeros in $B(z_0,r)\subseteq D$ for $k\geq K$. This implies that the map $z\mapsto \frac{1}{k}z_0 + \frac{k-1}{k}g^{-1}\big(f(z)\big) = z$ for all $k\geq K$, which is an obvious contradiction.
(e.g. observe this implies $h_k=0$ for $k\geq K$ which converges uniformly to $h\neq 0$).
Conclude $h=0\implies g^{-1}\big(f(z)\big) = z\implies f(z) = g(z)$ for all $z\in D$ as desired.