Glueing morphisms of sheaves together - can I just do this?

First, I think your notation $f_i^\sharp : \mathcal{O}_Y \to {f_i}_\ast(\mathcal{O}_X)|_{U_i}$ is slightly confusing. (If I were being very careful, and I usually am when I work with sheaves, I would write $f_i^\sharp : \mathcal{O}_Y \to {f_i}_\ast(\mathcal{O}_{U_i}) = {f_i}_\ast(\mathcal{O}_X|_{U_i}).$) Anyway, we have $$s_i := f^\sharp_i(s) \in {f_i}_\ast (\mathcal{O}_{U_i})(V) = \Gamma(f_i^{-1}(V),\mathcal O_{U_i}) = \Gamma(f_i^{-1}(V),\mathcal O_{X}).$$ Thus, we consider $s_i$ as a section of $\mathcal O_X$ on $f_i^{-1}(V)\subseteq U_i.$

Set $s_{ij} = f_{ij}^\sharp(s),$ where $f_{ij} = f_i|_{U_{ij}} = f_i\circ\iota_{ij},$ with $\iota_{ij}$ the inclusion of $U_{ij}$ into $U_i.$ Since we assume that $f_{ij} = f_{ji},$ it suffices to show that $s_i|_{f_i^{-1}(V)\cap U_{ij}} = s_{ij}.$ I claim the relevant property we need is the following:

Let $f:X\to Y$ and $g:Y\to Z$ be morphisms of locally ringed spaces. Then $f^\sharp:\mathcal O_Y\to f_\ast \mathcal O_X$ induces a morphism $g_\ast f^\sharp:g_\ast\mathcal O_Y\to g_\ast (f_\ast\mathcal O_X) = (g\circ f)_\ast\mathcal O_X$ of sheaves on $Z$ satisfying $(g\circ f)^\sharp = g_\ast f^\sharp\circ g^\sharp.$

This is essentially what it means to compose two morphisms of locally ringed spaces. To see why this is true, simply consider what happens on an open neighbourhood $V\subseteq Z.$ We want to use this when $X = U_{ij},Y = U_i,Z = Y$ (somewhat confusingly), and $f = \iota_{ij},g = f_i.$

We get $s_{ij} = f_{ij}^\sharp(s) = (f_i\circ\iota_{ij})^\sharp(s) = (f_{i\ast}\iota_{ij}^\sharp\circ f_i^\sharp)(s) = f_{i\ast}\iota_{ij}^\sharp (s_i)$ which is just $s_i$ restricted to $U_{ij},$ with notational bookkeeping that reminds us we have to consider these as sheaves on $Z.$ (Note that the definition of a morphisms of sheaves applied to the inclusion $U_{ij}\subseteq U_i$ guarantees that $\iota_{ij}^\sharp(s_i)$ is the same as restricting $s_i$ to $f_i^{-1}(V)\cap U_{ij}$ as considering it as a section of $\mathcal O_{U_{ij}}$.)


You are defining maps $$ \mathcal{O}_Y(V) \stackrel{s_i^V}{\longrightarrow} \mathcal{O}_X(f^{-1}(V) \cap U_i) = \mathcal{O}_X(f_i^{-1}(U))$$ and then wanting to use the fact that $U_i$ covers $f^{-1}(V)$ to define the unique value of $s^V$ by virtue of $\mathcal{O}_X$ being a sheaf. So we have to restriction maps $$\mathcal{O}_X(f^{-1}(V)\cap U_i) \stackrel{\mbox{res}_{ij}}{\longrightarrow} \mathcal{O}_X(f^{-1}(V)\cap U_i \cap U_j) \\ \mathcal{O}_X(f^{-1}(V)\cap U_j) \stackrel{\mbox{res}_{ji}}{\longrightarrow} \mathcal{O}_X(f^{-1}(V)\cap U_i \cap U_j) $$ and we want these maps to agree for outputs of $s_i$ . But what is the sheaf morphism for $f_i |_{U_i \cap U_j}$? It restricts $f_i$ to $U_j$, so it's exactly the map $$\mathcal{O}_Y(V) \stackrel{s_i^V}{\longrightarrow} \mathcal{O}_X(f^{-1}(V)\cap U_i) \stackrel{\mbox{res}_{ij}}{\longrightarrow} \mathcal{O}_X(f^{-1}(V)\cap U_i \cap U_j). $$ The assumed agreement of the restictions of the $f_i$ then gives the desired agreement of the restrictions of the $e_i^V$.