Every station has a statistical model they will be using to crunch the data.
The station inserts the numbers from early voting, exit polling, and actual vote counts into the model.
The model spits out a prediction.
When that prediction falls clearly outside the margin of error for the model, the station will call that state for a candidate.
The models are highly complex. They take into account historical voting patterns, demographics (age, race, salary, sex), geographical voting patterns, estimated turnout numbers, etc.