Would anyone please have a look at my proof for the following statement?
Let $X$ and $Y$ be topological spaces and $p: X \rightarrow Y$ a surjective continuous map. Consider the following property:
(A): For every topological space $Z$ and every continuous function $f: X \rightarrow Z$ such that $f(x)=f(y)$ if $p(x)=p(y),$ there is a unique continuous $g$ such that $f=g \circ p$.
Show that $(\mathrm{A})$ is satisfied if and only if there is a homeomorphism $h: Y \rightarrow X / \sim$ to the quotient space $X / \sim$ with the equivalence relation $x \sim y \Leftrightarrow p(x)=p(y),$ such that $h \circ p$ is the projection $\operatorname{map} X \rightarrow X / \sim$ We say that $(\mathrm{A})$ is the universal property of the quotient topology.
Proof:
[$\Rightarrow$] Let $\Pi: X \to X / \sim$ be the projection map, i.e. $\Pi(x) = [x] := \{z \in X: p(x) = p(z)\}$. For every $x,y \in X$ such that $p(x) = p(y)$, by defintion of $\Pi$, we have $\Pi(x) = \Pi(y)$. Then by the universal property $(A)$, there exists an unique continuous $h: Y \to X / \sim$ such that $\Pi = h \circ p$.
Similarly, if $x, y \in X$ such that $\Pi(x) = \Pi(y)$, then by definition of $\Pi$, we have $p(x) = p(y)$. $\Pi$ is clearly a surjective map, and $p$ is continuous by assumption, so by the universal property, there exists an unique $g: X / \sim \ \to Y$ such that $p = g \circ \Pi$.
$g$ and $h$ are continuous inverses of each other, since we have: $$p = g \circ \Pi = g \circ (h \circ p) = (g \circ h) \circ p, \text{ i.e. } g \circ h = \mathbb{I}_Y, \text{ and}$$ $$\Pi = h \circ p = h \circ (g \circ \Pi) = (h \circ g) \circ \Pi, \text{ i.e. } h \circ g = \mathbb{I}_{X / \sim}.$$
[$\Leftarrow$] Let $Z$ be a topological space and $f: X \to Z$ a continuous function such that $f(x) = f(y)$ if $p(x) = p(y)$. Define $\varphi: X / \sim \ \to Z$ as: $\varphi([x]) = f(x)$. As $\varphi([x]) = \varphi \circ \Pi(x) = f(x)$, and as both $\Pi$ and $f$ are continuous, $\varphi$ is also continuous.
We check that $\varphi$ is well-defined. Assume for a contradiction that it is not. Then there exists $S \in X / \sim$ such that $S$ is mapped by $\varphi$ to both $z_1$ and $z_2$ in $Z$, where $z_1 \neq z_2$. Since $S \in X / \sim$, $S$ is of the form $\{x_1,x_2,... \in X: p(x_1) = p(x_2) = ...\}$. Since $S \mapsto z_1$, this implies $p(x_1) = p(x_2) = ... = z_1$, and, similarly, since $S \mapsto z_2$, this implies $p(x_1) = p(x_2) = ... = z_2$. But this means $p(x_1) \neq p(x_1)$, a contradiction.
Now define $g = \varphi \circ h$. As the composition of continuous functions, $g$ is continuous. $g$ is well-defined since both $\varphi$ and $h$ are well-defined, and for any $x \in X$: $$g \circ p(x) = \varphi \circ h \circ p(x) = \varphi \circ \Pi(x) = \varphi([x]) = f(x)$$
We show that $g$ is unique: assume $g': Y \to Z$ is a continuous function such that $f = g' \circ p$. For all $y \in Y$, we want to show that $g'(y) = g(y)$. Now since $p$ is surjective, there exists $x \in X$ such that $p(x) = y$. Then we have: $$g'(y) = g'(p(x)) = g' \circ p(x) = f(x) = g \circ p(x) = g(p(x)) = g(y)$$
Some comments: