Why is MacBook pro 2018 magnetic on the back?

MacBooks use magnets to detect whether they are open or closed (and trigger the according actions like going to sleep/clamshell mode, etc.) and to magnetically keep the MacBook shut.