Replacement knobs are also available at Lowe's and Home Depot and may be cheaper than buying glue. If you have a glue gun a shot of hot glue may be enough to keep it together. Otherwise a glue designed for plastics, like a super glue.
I suspect that the decorative wall plate, with the escutcheon in 1st photo, prevents the knob from fully engaging the dimmer shaft, and while esthetically unappealing, simply leaving the escutcheon removed, or changing the trim to a flatter option, would be a cure.
This may not even be applicable here but if anyone works with PVC pipe the cement Handy Pack always has way too much purple primer. Except for the awful purple color it seems to be the same as the stuff kids used to weld those plastic car models together. Just don't use that swab for application use a small brush and not where purple is a problem.