Twisted bilayers of two-dimensional materials, such as twisted bilayer graphene, often feature flat electronic bands that enable the observation of electron correlation effects. In this work, we study the electronic structure of twisted transition metal dichalcogenide (TMD) homo- and heterobilayers that are obtained by combining MoS$_2$, WS$_2$, MoSe$_2$ and WSe$_2$ monolayers, and show how flat band properties depend on the chemical composition of the bilayer as well as its twist angle. We determine the relaxed atomic structure of the twisted bilayers using classical force fields and calculate the electronic band structure using a tight-binding model parametrized from first-principles density-functional theory. We find that the highest valence bands in these systems can derive either from $Gamma$-point or $K$/$K$-point states of the constituent monolayers. For homobilayers, the two highest valence bands are composed of monolayer $Gamma$-point states, exhibit a graphene-like dispersion and become flat as the twist angle is reduced. The situation is more complicated for heterobilayers where the ordering of $Gamma$-derived and $K$/$K$-derived states depends both on the material composition and also the twist angle. In all systems, qualitatively different band structures are obtained when atomic relaxations are neglected.