Count what is attached to a carbon — bonded atoms plus lone pairs. That count, the steric number, fixes the shape:
- 4 → sp³, tetrahedral, 109.5°
- 3 → sp², trigonal planar, 120°
- 2 → sp, linear, 180°
The electrons repel each other and end up as far apart as possible. That is the whole derivation.