Its the same way as an ice cube melts in hot water. The heat from the hot chocolate causes the bonds to disassociate and melts the marshmallow! All substance melt at a certain temperature and its called the melting point. Sometimes this can be really high like 250*C other times its really low. Marshmallows melt at about 60 degrees I would reckon!
However, as the marshmellow contains a mixture of different ingredients, it will soften slowly around the melt point and get more and more plastic (squishable) before it turns entirely liquid. This is the same for other materials such as most polymers (plastics!) and wax, where you have a range of different molecular weights of the material.
This is quite different behaviour to things such as ice which have a very well defined and sharp transition point, so you end up with two distinct phases (frozen, and not frozen), rather than the whole thing softening.