Magic-angle twisted bilayer graphene displays at different fillings of the four flat bands lying around the charge neutrality point a wealth of notable phases that include magnetic Chern insulators, whose magnetization is mostly of an orbital nature and contiguous superconducting domes. Such a rich phase diagram is explained through the positive interplay of Coulomb repulsion and the electron coupling to a twofold optical mode that corresponds to Kekul\'e distortions localized into the small AA stacked regions of the moir\'e supercells. A static distortion stabilizes, at any integer filling of the flat bands, valence-bond insulators that carry finite Chern number away from charge neutrality. Similarly, a dynamic distortion that resonates between the two lattice vibrations leads to resonating-valence-bond topological insulators with built-in chiral d-wave pairs that have finite Chern number equal to the angular momentum, and thus are prone to turn superconducting upon doping away from integer filling.