Why is D not a valid answer for this question?
D would not be a valid answer if you think about what forms or what happens that leads to formation of cyclic hemiacetal. In the course of formation of cyclic hemiacetal, the -OH oxygen has 2 lone pair and the C=O carbon has partial positive charge on it and so, in a nutshell the -OH oxygen attacks the carbon with partial positive charge and this leads to formation of hemiacetal. Now,the -OH is attached to 4th C atom and so during the course of ring formation, the 5th carbon will always lie outside the ring and this the reason why D cannot be a valid answer.
A scheme of this critical mechanism step is shown below. The carbon atoms are numbered for clarity. Additionally, the methyl group on carbon 5 is circled. Since the mechanism of the ring closure does not involve carbons 2-5, the structure cannot change at those positions.