By combined top- and backgating, we explore the correlation of superconductivity with band filling and electron confinement at the LaAlO$_3$-SrTiO$_3$ interface. We find that the top- and backgate voltages have distinctly different effects on the superconducting critical temperature, implying that the confining potential well has a profound effect on superconductivity. We investigate the origin of this behavior by comparing the gate-dependence of $T_c$ to the corresponding evolution of the band filling with gate voltage. For several backgate voltages, we observe maximum $T_c$ to consistently coincide with a kink in tuning the band filling for high topgate voltage. Self-consistent Schrodinger-Poisson calculations relate this kink to a Lifshitz transition of the second $d_{xy}$ subband. These results establish a major role for confinement-induced subbands in the phase diagram of SrTiO$_3$ surface states, and establish gating as a means to control the relative energy of these states.