Theory of two-dimensional coherent spectroscopy with application to Kitaev magnets and Nb superconductors