Search for narrow and broad dijet resonances in proton-proton collisions at sqrt(s) = 13 TeV and constraints on dark matter mediators and other new particles