I haven't been to a competition yet, but I know each individual recorded solve must have a judge to be verified (the judges are people who make sure there aren't any problems, ie DNFs or anything), and I think its the judges that scramble them. They have a few rules about how to scramble the cubes, like you can't keep doing the same two moves over and over and then change positions on the cube, all the moves have to be different and not in a pattern, also competition scrambles are always around 20 moves, but usually not more, etc, etc. There is also a very popular online timer called CSTimer, that cubers at home will often use if they do not have a timer (I do, but I still use it sometimes cos is cool), and that will generate sets of moves for you, which youcan then do to the cube and scramble it. Its quite complicated :)