When your robot follows a line, it is actually following an EDGE between light and dark.
When it senses the light (greater reflection from the surface), it must turn toward the dark - in this case LEFT.
When it senses dark (less reflection from the surface), it must turn toward the light - in this case RIGHT.
In this way, it "waddles" along the edge. The smaller you make the turns, the smoother its pathway will be.
Spike Prime Line Follow
Notice! The color sensor is raised above the ground, facing down so that it can scan the ground for reflected light. There is no specific way you have to attach your color sensor as long as it is about a centimeter off the ground.
This video explains how to make your robot follow a line in Spike Prime.
This is a good, simple line follow program.
This one works as well.
One more.
There are other ways to do a line follow. You are not limited to these codes.
Line Follow Lesson - if you are intrigued by this programming concept, follow this link for an in-depth lesson about line-following, and autonomous driving.