I guess they randomly decide the order that they draw the units in?
The others who stated they draw the application are correct. For a non resident to draw a tag in a unit where only 2 tags are available his application would have to have been the first or second application drawn with that unit as a first choice. However if by chance the first application drawn was a different non resident then the non resident cap would be filled and only resident hunters would be eligible for the second tag.
As for the second choice sheep question the only way to get a second choice is to have more tags than first choice applications. I'm not sure if that has ever happened.