Addition of acid to 3-methyl-2,3-dihydropyran
Apparently, you're using the Markovnikoff's rule here. Recall that it is only a basic rule intended for simple unsaturated hydrocarbons, and fails at more advanced examples involving heteroatoms or rings.

In this case, the first step is the addition of $\ce{H+}$ ion from the acid to the pi bond, which leads to the formation of a carbocation. The carbocation's positive charge is most stable next to the oxygen atom. Can you tell why?

In the second step, the $\ce{X-}$ ion will simply attach at the position where the positive charge was the most stable, leading to a product as you've shown in the second image.