I quite don't understand whom are people voting for in the primaries. Do they vote for candidates themselves or for delegates? If I understand it correctly, people vote for candidate and the winner of that state primaries will have all votes of pledged delegates? (If the state has winner takes all policy.)
What is a Primary?
Primaries are held before the United States Presidential election to decide who will be each party's candidate. The rules of the primary (or caucus) are not specified by the Constitution, they are internal business for the political party to decide who it should field as their candidate.
To be a bit more technical, not all parties in all states have primaries, many have caucuses. To avoid sounding weird in this answer I'll call both primaries (although professional literature often says "primaries and caucuses")
How Does it Work?
Well, it varies by party and state.
The state's winner-take-all rules don't apply here because it is not a public election; this is the party's internal business.
Generally speaking, a primary is also an indirect election. When you cast a vote in the primary, you are really electing a state elector who will attend the party's national convention. They are pledged to vote for the same candidate that wins the primary in their district. To answer a question from the comments: yes, these electors are also called delegates.
Districts vary from state to state and party to party. In my state (Kansas), primaries follow state Senate districts (the state legislature has a House and Senate, just like the national Congress does). Districts should have roughly equal populations, but otherwise the state is free to redefine these districts as they please.
In another state, the party could have drawn districts for their caucus entirely differently. This would result in the two states having a very different ration of voters-to-delegates.
Source: Wikipedia article on United States presidential primaries and caucuses. This is a bit of general knowledge of American political process, so I hope wikipedia will suffice. If not, let me know and I will dig up some primary sources.