To keep it simple, it depends on the state. Some states, such as Iowa, hold caucuses which are attended only by party members. In the states that hold primaries, it depends on whether or not the primary is "open" or "closed". An open primary allows anyone to vote in any primary regardless of party affiliated while a closed primary is supposed to have Republicans voting in the Republican primary and Democrats voting in the Democrat primary although I'm sure that doesn't always happen.
In 2000, Democrats tried to throw the Republican primary to McCain by voting in the open Republican Primaries. Today, I seriously doubt that enough Republicans crossed over to help Kerry. If they did, then Howard "Screaming" Dean would have been the nominee or at the very least the battle for the nomination would still be happening.
So how did Kerry win the nomination? Simply. Dean's campaign implode thanks to two factors. Dean scuttled his campaign by showing how off the deep end he really was and those torpedoes in the back from the Clintons didn't help him either. If Dean had won the nomination, he would have cleaned out the Clintonites from the DNC, something Hillary cannot allow if she wants to run for President in 2008.
"There is no victory at bargain basement prices."