Isomorphism of Hom sheaf Let $\mathcal F$ be a sheaf of abelian groups on $X$. The claim is that $\text{Hom}(\mathcal Z,\mathcal F)\cong \mathcal F$, where $\mathcal Z$ is the constant sheaf on $\mathbb{Z}$. There is a similar question on here, but it doesn't go into much detail. In particular, I am hoping to find gaps in my current reasoning.
So, let $f\in\text{Hom}(\mathcal Z,\mathcal F)(U)=\text{Hom}(\mathcal Z|_U,\mathcal F|_U)$. Note that for any $V\subset U$, we have $\mathcal Z(U)=\mathbb{Z}$. Then for any open set $V\subset U$, we get abelian group morphisms $f(V):\mathbb{Z}\rightarrow F|_U(V)$ that commute with restriction maps.
My question is how does this help is identify an isomorphism between the two sheaves? I suppose for every such $V$ and $f$, we get an element $F(V)$, which gives us a map in one direction from $\text{Hom}(\mathcal Z,\mathcal F)(V)$ to $\mathcal F(V)$. Conversely, Given an $\mathcal F(V)$, we get an abelian group homomorphism from $\mathbb{Z}$ to $\mathcal F(V)$. But then how can we see that these maps all commute with restriction maps?
 A: First of all, I suggest a slight change of notation. $\mathrm{Hom}(Z,F)$ usually denotes the hom-set, and to avoid confusion we should make it clear when referring to the hom-sheaf instead: common notation is $\underline{\mathrm{Hom}}(Z,F)$ or $\mathcal{H}\kern{-1pt}\mathit{om}(Z,F)$. Moreover, I suppose you denote by $Z$ the constant sheaf with stalk $\mathbb Z$ on $X$, not on $\mathbb Z$ (viewed as a discrete topological space).
I should also point out that $Z(U)$ is not $\mathbb Z$, but the direct sum of as many copies of $\mathbb Z$ as the connected components of $U$. The constant presheaf is not a sheaf, and the constant sheaf $Z$ is the sheafification of the constant presheaf, or if you prefer $Z=p^{-1}\mathbb Z$, the pullback where $p\colon Z\to \bullet$ is the map to a point and $\mathbb Z$ is viewed as a sheaf on $\bullet$.
Back to your question, I would split the proof in three parts. First, you recall that in the category of abelian groups, there is a group homomorphism $\mathrm{Hom}(\mathbb Z,G)\simeq G$ since a morphism $\mathbb{Z}\to G$ is completely determined by the image of $1\in\mathbb Z$.
Secondly, you show that, for all $x\in X$, $\mathcal{H}\kern{-1pt}\mathit{om}(Z,F)_{x}\simeq\mathrm{Hom}(Z_x,F_x)=\mathrm{Hom}(\mathbb Z,F_x)$. As pointed out by Roland in the comments, the first isomorphism is not true if we replace $Z$ by any sheaf.
Thirdly, you use the fact that a sheaf morphism $\phi\colon H\to F$ is an isomorphism if and only if it is on the level of stalks, that is $\phi_x\colon H_x\stackrel{\sim}\to F_x$ (Proposition II.1.1 in Hartshorne's Algebraic Geometry). Then specialise to $H=\mathcal{H}\kern{-1pt}\mathit{om}(Z,F)$.
I hope this is helpful.
