The sed command uses a substitute command ( s/.../... / ) . The first part of the expression contains a basic regular expression (regex). The escaped parentheses \( and \) are used to group parts of matched text that can be back referenced by \1 in the second part of the s-command.
So in this case only the second colon is outside the grouped part and does not get back referenced, so effectively it gets discarded. If we apply this to your input file then the first match is :8: , which gets substituted with :8| . At the end of the expression is the letter g , which is the "global" flag, which means that the operation should be repeated for every occurrence on the line.
So this will be repeated, and crucial here, is that the next match will start after the previous match, so next up will be :4: which becomes :4| and then :14: becomes :14| and so on...