This question is motivated by Example 5.2.4 in Algebraic Geometry by Hartshorne (page 112). As far as I understand, it claims that if $Y$ is a closed subscheme of $X$, and one considers the inverse image of $\mathcal{O}_X$ under the inclusion of $Y$ (labeled in the book by $\mathcal{O}_{X|Y}$), then the resulting sheaf on $Y$ might not be a sheaf of modules, or even if it is, then it won't be quasi-coherent.
As there is no counterexample given, I am wondering what the reason for this might be. Is it because $\mathcal{O}_{X|Y}$ is not an $\mathcal{O}_Y$ module for the particular choice of the structure on $Y$, or would it be independent of what the chosen structure sheaf on $Y$ would be, as long as it gives a closed immersion?
To elaborate: If I restrict my consideration to affine schemes. Then $X = Spec(A)$ and $Y = Spec(A/\alpha)$. Does $\mathcal{O}_{X|Y}$ not being an $\mathcal{O}_Y$-module correspond to choosing an incorrect $\alpha$?
An additional question related to this would be: When does $\mathcal{O}_{X|Y}$ give a structure sheaf of a scheme on $Y$? If it were possible always, then it would mean for the previous question that we can always choose a structure sheaf on $Y$ such that $\mathcal{O}_{X|Y}$ is a sheaf of modules.