Vertices—loop indices vs. unique indices
In Blender, Vertex Color maps don't assign a single color to each vertex but instead assign a color to each vertex of each polygon, as described in this answer by zeffii.

As you noted, loop indices are not unique. So if you want to assign a color the vertices by their unique index you would have to create a mapping of vertex indices to loop indices, i.e. for each polygon, map poly.vertices to poly.loop_indices:

import bpy
from collections import defaultdict

obj = bpy.data.objects['Cube']
col = obj.data.vertex_colors['Col']
polygons = obj.data.polygons

vertex_map = defaultdict(list)
for poly in polygons:
    for v_ix, l_ix in zip(poly.vertices, poly.loop_indices):
        vertex_map[v_ix].append(l_ix)


Once this is done, vertex_map will be a dictionary with the unique vertex indices as keys and lists of loop indices as the values. E.g. something like this for the default cube:

{ 0: [0, 8, 21],
  1: [1, 11, 12],
  2: [2, 15, 16], ... etc.
}


To assign the colors, you can now loop over the dictionary and set the color for each loop index of each vertex:

# color vertices 0 to 3 in red, all other vertices white
for v_ix, l_ixs in vertex_map.items():
    for l_ix in l_ixs:
        if v_ix in [0, 1, 2, 3]:
            col.data[l_ix].color = (1, 0, 0)
        else:
            col.data[l_ix].color = (1, 1, 1)