The genuine remorse, sadness and humiliation on realization of committing sins acts as a catalyst in spiritual progress of a salik.
It makes him aware of his deficiencies. The self-praise (ujub) and arrogance (kibr) are wiped off. A stronger feeling of dependency on Allah’s mercy and grace develops. He make more supplications and turning to Allah (ruju illAllah) with humility asking for forgiveness and protection from future such calamities.
In summary the mistakes of those on the path become a stepping stone for them in their progress.
(This is true only for the sincere salik who is trying his best and occasionally slips because of his ba-shar-iyat (humanness). This discussion can not be used to justify sinning by those who intentionally plan and commit sins.)