CNN explains how they did it in 2008. They share the basic data, relying on services like the Associated Press and Edison Media Research for that.
The Associated Press: The Associated Press will provide vote totals for each race. The AP will be gathering numbers via stringers based in each county or other jurisdiction where votes are tabulated.
Edison Media Research: To assist CNN in collecting and evaluating this information, CNN, the other television networks and The Associated Press have employed Edison Media Research (EMR). In previous elections, this firm has assisted CNN in projecting winners in state and national races. EMR will conduct exit polls, which ask voters their opinion on a variety of relevant issues, determine how they voted, and ask a number of demographic questions to allow analysis of voting patterns by group.
Using exit poll results, scientifically selected representative precincts, vote results from The AP, and a number of sophisticated analysis techniques, EMR also recommends projections of a winner for each race it covers.
Each network can also call the race on its own. But since they share the data sources and don't want to be last to report the news, there is pressure to agree.
In 2000, the networks called Florida for both Gore and Bush before finding out that it was within the recount margin. This was prior to EMR. The service that year was called Voter News Service.