Why do people do only 3 sets in the gym?
Three sets may be a good general rule to follow, however there is nothing magical about it. The number of sets you choose to do might be based on level of experience on a movement and the nature of the movement. For very beginners, try 1 or 2 sets. Over time you may want to progress to 3 or more. For movements that involve smaller muscle groups, therefore lower levels of resistance, less sets may do the trick. For bigger stronger movements, more experienced exercisers may need more sets in order to keep progressing. With these there is a distinction between "warmup sets" and "working sets." Warming up for lifting is important. Even the serious powerlifters I know start with an empty bar or light weights and work up gradually to the heavy or hard working sets. This gives you the opportunity to dial in your body mechanics prior to loading up heavy.
Check out this video for more info on exercise program design including a basic set/rep structure: