tl;dr A slightly anthropomorphic approach with some basis in general organic chemistry:
Step 1: The protonation of the carbonyl (An acid-base reaction)
Here, we have three options – we can protonate the nitrogen (deactivated by the resonance with oxygen), the alcohol group ($\mathrm{sp^3}$) or the carbonyl group ($\mathrm{sp^2}$). As you can see this is basically an acid-base reaction and therefore the strongest base (having highest electron density) would react the fastest and this means since the carbonyl has the highest electron density here the carbonyl is protonated.
Step 2: The intermolecular attack ($\ce{O}$ is very sneaky)
Well, we began with $\ce{HCl}$. Time for the $\ce{Cl-}$ to make an appearance? Not really. As you can see, we have an alcohol group in the compound which has electrons to donate. The carbon on the (protonated) carbonyl group is highly electropositive (It was positive enough when there was no positive charge on the oxygen and now it just got more electropositive). Now, the oxygen with the lone pair makes an appearance. It attacks the carbonyl carbon and at the same time the π electrons move to the previously protonated oxygen making it neutral.
Step 3: An intermolecular proton transfer (Another acid-base reaction?)
Now, as you may have learnt, oxygen is not the most electropositive element. If possible, it doesn't stay positive. Nitrogen comes to the rescue. Another acid base reaction takes place where the newly active amine group deprotonates the oxygen forming $\ce{>NH2+}$.
Step 4: The final rearrangement (We're done here(?), you can figure it out)
We still need the final isomer and we also need to remove the positive charges on the compound before we end. Therefore, the ring breaks and the electrons move to the nitrogen removing the positive charge on it. This also means a carbocation is formed in the carbon where the alcoholic group is attached which stabilises it using resonance to form a $\ce{C=OH+}$ bond. (try drawing this step).
But we aren't done.
Step 5: The true final step (A small deprotonation)
Nobody needs any positive oxygens, do we? Therefore the oxygen is deprotonated. (Note: this is in equilibrium since medium is acidic). All $\ce{H+}$ used has been released which also makes this a catalytic reaction.
There might be one final question in the back of your mind (for the curious).
Why not go back to the starting compound?
This is because as @user55119 very well pointed out in a comment to the other answer. My additions in italic.
In the absence of acid, heating amino ester (a) would give the starting material, the hydroxyamide because esters are more labile (easily broken down or displaced) than amides. The reason this reaction can occur is that the amino group is protonated in acid which shifts the equilibrium.
Welcome to the realms of organic chemistry.