It depends on the transmission manufacturer and the model of the transmission. In the '80s and before, an automatic transmission was controlled by a vacuum actuator and a cable which ran to the throttle (called a TV cable). Later in the '90s, when electronic engine management came into play, transmissions started being controlled by a main computer in the car (or Powertrain Control Module - PCM). This controlled a lot of aspects of the tranny, to include shifting, line pressures, torque converter lockup and other operations. Sometime later, some manufacturers started dividing the Transmission Control Module (TCM) and Engine Control Module (ECM) back out so there are actually two controllers doing the work, while talking to each other.
Shifting the gears is dependent on several different factors, such as engine load, throttle position, speed of the vehicle, engine speed, etc. Every manufacturer does it a little different, so I won't try to go into it.