Apple's compatibility table for the Magic Keyboard for the iPad Pro 11" has been updated - and states compatibility with the new iPad Air 11" M2:

Clearly your existing Magic Keyboard for iPad Pro/Air 11" is not compatible with the new iPad Pro M4 models.
Setting aside the performance difference between M2 and M4 CPUs (which, for practical purposes, might only be apparent when using pro-level Apps explicitly designed for CPU-intensive tasks), the principal differences between the M2 and M4 devices are the new Ultra Retina XDR OLED screen and the option of nano-texture glass for the 1TB/2TB storage models. Additionally for the iPad Air M2 vs the iPad Pro M4, the rear camera array substantially differs.