#JavaScript, 57 bytes

<!-- language: lang-js -->

    F=(a,b)=>b?F(a.replace(/(.)\1*/g,c=>c.length+c[0]),b-1):a

Recursion works well for this problem.