However, a phase transition it is also associated with a change of the
potential energy of the molecules. I don't see how this parameter is
included in the equation for latent heat.
The total internal energy of the substance is the sum of its molecular kinetic and potential energies. Since the temperature of the substance during the phase transition is constant, and temperature is a measure of the kinetic energy component of the internal energy of the substance, there is no change in the kinetic energy component of the internal energy of the substance during the phase transition.
Given the above, the heat transfer during the phase transition has to equal the change in the molecular potential energy component of the internal energy. Where else would the energy go or come from?
What I don't understand is how a change in entropy of the gas reflects
the whole change in the potential energy of the molecules in a case of
a gas for example?
This is in response to your above comment.
The increase in molecular potential energy during a phase change from a liquid to a gas results in the gas occupying a greater volume than the liquid. Gas molecules move more freely and are more "spread out" than in a liquid. Therefore the molecules have more room and more positions in which they can potentially be arranged. The more positions or microstates that can be occupied, the greater the entropy.
Hope this helps.