Enumerate each series of identical numbers in-place
JavaScript (ES6), 26 bytes
1-indexed.

a=&gt;a.map(o=x=&gt;o[x]=-~o[x])

Try it online!
Commented
a =&gt;                // a[] = input array
  a.map(o =         // assign the callback function of map() to the variable o, so that
                    // we have an object that can be used to store the counters
    x =&gt;            // for each value x in a[]:
      o[x] = -~o[x] //   increment o[x] and yield the result
                    //   the '-~' syntax allows to go from undefined to 1
  )                 // end of map()