Run two separate binary searches: one to find the leftmost occurrence, one to find the rightmost.
For the leftmost: when you find the target, don't stop. Record the position and keep searching left (right = mid - 1). This ensures you find the first occurrence.
For the rightmost: when you find the target, record it and keep searching right (left = mid + 1).
With nums = [5, 7, 7, 8, 8, 10] and target = 8: the left-biased search finds index 3. The right-biased search finds index 4. Return [3, 4].