Jesusemora is correct. To elaborate just a little, vertexes are the points in a polygon of a mesh. Most often in 2D it will be like you have here, with 4 of them, one in each corner. In the vertex() function, COLOR serves to get/set the color stored exactly in that particular vertex. Sometimes meshes will have a vertex color already baked in, if an artist was using it for something. In the fragment() function, the get and set from color actually do two different things: getting COLOR gets the now-interpolated value from the vertex colors. Setting COLOR sets usually the final color you see rendered on the texture in 2D, although that isn't true if there is 2D lighting involved.
As for avoiding if/else, often you can use the step function instead, like this:
vec4 xcolor(in vec2 uv){
float s = step(0.5, uv.y);
return vec4(0.0,1.0,0.0,1.0) * s + vec4(1.0,1.0,1.0,1.0) * (1.0 - s);
}