Since Apple already replaced your keyboard unit and the problem persisted, the issue is not hardware-related to the Magic Keyboard itself. The keyboard backlight slider snapping back to zero is almost always caused by an ambient light sensor restriction or a specific iPadOS Accessibility glitch.
The Magic Keyboard does not have its own ambient light sensors; it relies entirely on the iPad's built-in light sensor (located near the front-facing camera). If the room you are in is brightly lit, iPadOS will actively block you from raising the slider to prevent battery drain. Alternatively, a software conflict is overriding your manual input.
Try this
An ongoing iPadOS glitch causes the AssistiveTouch feature to lock the keyboard backlight slider at zero.
- Go to Settings > Accessibility > Touch > AssistiveTouch.
- Toggle AssistiveTouch OFF.
- Try adjusting your keyboard brightness slider again to see if it holds its position.