Joining all the keys of a list of rules that point to matching values

There are many ways, here's one:

KeyValueMap[#2 -> # &] @ GroupBy[rules, Last -> First, Flatten]

Reverse /@ (Flatten /@ PositionIndex[Association@rules] // Normal) 

{{a, b, c} -> 1, {d, e, f} -> 2, {g, g} -> 3, {g} -> 4}

In addition:

Flatten /@ PositionIndex[Association@rules]

<|1 -> {a, b, c}, 2 -> {d, e, f}, 3 -> {g, g}, 4 -> {g}|>


KeyValueMap[#2 -> #&] @ Merge[Flatten][Reverse /@ rules]

{{a, b, c} -> 1, {d, e, f} -> 2, {g, g} -> 3, {g} -> 4}

Als0

Flatten[#[[All, 1]]] -> #[[1, -1]]& /@ GatherBy[rules, Last] 

{{a, b, c} -> 1, {d, e, f} -> 2, {g, g} -> 3, {g} -> 4}

and

Values @ GroupBy[rules, Last, Flatten @ #[[All, 1]] -> #[[1, -1]]&] 

{{a, b, c} -> 1, {d, e, f} -> 2, {g, g} -> 3, {g} -> 4}