If a person is affiliated with a party (Democrat or Republican) they can vote in a primary for the choices their respective parties offer.
If a person is unaffiliated (independent) they can declare an affiliation at the polling place and vote accordingly. If they wish to remain unaffiliated after the election, the contact the board of election and will be sent a form for them to fill out basically stating their wish to remain unaffiliated.
They can do that each time a primary occurs, and that way can always vote in a primary but never be affiliated with a party long term.
If a person is affiliated with a party and wishes to change their affiliation, they must contact the board of election (the county clerk's office 908-527-4787) and complete a form 55 days prior to the primary election.
If by some chance a polling worker allows someone of a particular affiliation to vote for a candidate with whom they are not affiliated, that vote will be voided.
A PDF version of the Summit sample ballot can be found here.