Quantum Kibble–Zurek mechanism and critical dynamics on a programmable Rydberg simulator