A Primary Election occurs when you have more candidates running for an elected position on the same party line, than there are positions to be filled. Only when this happens is a Primary Election held. The Primary Election is only held for that party and position.
Registered voters of the party(s) having a primary get the opportunity to vote for the candidate(s) they want to represent them on the ballot in November.
Primaries are very important - but there is normally a very low turnout.