The process for setting NCAA basketball lines is like other pro or college sports. Essentially, casinos and bookmakers try to set a line that balances the dollars being wagered on each side, so the casino has no principal risk. After the opening line is set, the line will then fluctuate as money comes in on either side of the bet.
A line may open as Virginia is a -5 favorite versus North Carolina. But if the public feels that North Carolina has a great chance to cover the spread (or even win the game outright), a majority of the money might come in at North Carolina +5 and balance out the line. Then, the book would adjust the line down, e.g., Virginia -4.5 or -4, to balance out the money totals.