  Recently, KFe$_2$As$_2$ was shown to exhibit a structural phase transition
from a tetragonal to a collapsed tetragonal phase under applied pressure of
about $15~\mathrm{GPa}$. Surprisingly, the collapsed tetragonal phase hosts a
superconducting state with $T_c \sim 12~\mathrm{K}$, while the tetragonal phase
is a $T_c \leq 3.4~\mathrm{K}$ superconductor. We show that the key difference
between the previously known non-superconducting collapsed tetragonal phase in
AFe$_2$As$_2$ (A= Ba, Ca, Eu, Sr) and the superconducting collapsed tetragonal
phase in KFe$_2$As$_2$ is the qualitatively distinct electronic structure.
While the collapsed phase in the former compounds features only electron
pockets at the Brillouin zone boundary and no hole pockets are present in the
Brillouin zone center, the collapsed phase in KFe$_2$As$_2$ has almost nested
electron and hole pockets. Within a random phase approximation spin fluctuation
approach we calculate the superconducting order parameter in the collapsed
tetragonal phase. We propose that a Lifshitz transition associated with the
structural collapse changes the pairing symmetry from $d$-wave (tetragonal) to
$s_\pm$ (collapsed tetragonal). Our DFT+DMFT calculations show that effects of
correlations on the electronic structure of the collapsed tetragonal phase are
minimal. Finally, we argue that our results are compatible with a change of
sign of the Hall coefficient with pressure as observed experimentally.
