I've not Hartshorne's book with me now so I cannot check the exact context of your question, anyway this is a very general fact about localization. Take a Grothendieck category $\frak C$ and a hereditary torsion subclass $\frak T$, then you have a localization of categories $Q:\frak C\to \frak C/\frak T$ (in the sense of Gabriel). There is always a fully faithful functor $S:\frak C/\frak T\to\frak C$ such that $(Q,S)$ is an adjoint pair. By the closure properties of $\frak T$, the quotient functor $Q$ is automatically exact.

Now, identifying $\frak C/\frak T$ with a subcategory of $\frak C$ via the section functor $S$, you have a very explicit construction of the localized objects using the torsion-theoretic machinery. Indeed, denote by $T:\frak C\to \frak T$ the torsion functor (for an object $C\in \frak C$, $T(C)$ is the direct union of all the sub-objects belonging to $\frak T$).

Given $X\in \frak C$, let $X'=X/T(X)$, then $Q(X)$ is isomorphic to $\pi^{-1}(T(E(X')/X'))$, where $\pi:E(X')\to E(X')/X'$ is the natural projection.

Now, in some cases you can prove that the class $\frak T$ is closed under taking injective envelopes. This is the case for example the case of localization at prime ideals in commutative Noetherian rings. This is not always the case in non-commutative (even Noetherian) rings, something can be said in the case of FBN rings. If $X$ is injective from the beginning and the torsion class is closed under taking injective envelopes, then it is an exercise to prove that $T(X)=X_t$ is again injective and so you have $X=X_t\oplus X_f$ for some torsion-free injective object $X_f$. Thus $Q(X)\cong Q(X_f)$. Furthermore, $E(X_f)/X_f=0$ and so $Q(X_f)\cong X_f$ is injective.

Anyway, not every "localization" is the localization with respect to a hereditary torsion theory and, even in that case, the torsion class is not always closed under taking injective envelopes so that the above argument does not always apply... In this moment it is not clear to me what happens for a general universal localization or for Cohn's localization.