From here:
I'm trying to verify that the isomorphism $\mathscr P(A)\cong H_2(A)$ is natural in $A$.
Let $f^{op}:A\to B$ be an arrow in $\mathbf{Set}^{op}$ (so $f:B\to A$ is an arrow in $\mathbf{Set}$). We need to verify that the diagram
$$ \require{AMScd} \begin{CD} \mathscr P(A) @>{\mathscr P(f^{op})}>> \mathscr P(B);\\ @VVV @VVV \\ H_2(A) @>{H_2(f^{op})}>> H_2(B); \end{CD}$$
commutes.
If we first go right and then down, then $U$ first gets sent to $f^{-1}(U)$ and then to the characteristic function $\chi_{f^{-1}(U)\subset B}$ of the subset $f^{-1}(U)\subset B$.
If we first go down and then right, then $U$ first gets sent to the characteristic function $\chi_{U\subset A}$ of $U\subset A$ and then to $\chi_{U\subset A}\circ f$.
One thing that got me confused is this: we have an arrow $A\to B$ (i.e., a function of sets), how is the arrow (function) $B\to A$ chosen? For example, if $A=\{\star,\ast\},B=\{\cdot\}$ and the functon $A\to B$ sends $\ast,\star\mapsto \cdot$, then we cannot construct a function $B\to A$ by sending $\cdot$ to both $\star,\ast$, so one has to make a choice.
And secondly, I don't quite see why the two compositions described above are the same.

The arrows in $\mathbf{Set}$ are functions. The arrows in $\mathbf{Set}^{op}$ are also functions, except we flip our labels for domain and codomain. So for example, there is a constant function $\{*,\star\}\to\{\bullet\}$ in $\mathbf{Set}$. This same function counts as an arrow $\{\bullet\}\to\{*,\star\}$ in $\mathbf{Set}^{op}$. In moving to the opposite category, we simply flip the labels for domain and codomain; the behavior is the same.
Pick a function $f:B\to A$ in $\mathbf{Set}$. We can view it as an arrow $f^{op}:A\to B$ in $\mathbf{Set}^{op}$.
Then $\mathscr{P}(f^{op}:A\to B)$ is a function from $\mathscr{P}(A)$ to $\mathscr{P}(B)$. It sends subsets of $A$ to their inverse image in $B$ under $f$. Note that because $f$ is a function from $B\to A$, this checks out.
And $H_2(f^{op}:A\to B)$ is a function from $2^A$ to $2^B$. Given a function $A\to 2$, you can pre-compose with $f$ to get a function $B\to A \to 2$.
The isomorphism $\mathscr{P}(A)\to H_2(A)$ sends each subset $U$ to its characteristic function $\chi(u) = \begin{cases}1, u\in U\\ 0, u\notin U\end{cases}$.
It is natural because one way – right then down – we get the map that sends each subset $U$ of $A$ to the characteristic function of $f^{-1}(U)$. In other words, each subset $U\subseteq A$ gets sent to the map $\small(B\to 2)$ which assigns $1$ to every point $x\in B$ with $f(x)\in U$ and $0$ to every other point.
The other way – down then right – $U$ gets sent to the characteristic function of $U$ pre-composed with $f$. In other words, this composition sends each point $x\in B$ to $f(x)$, then returns $1$ if $f(x)\in U$ and returns $0$ otherwise. This is the same function as before, so the isomorphism is natural.