2024? There's still plenty of time for them to remove the port altogether and go with just MagSafe/Qi. Which they control, and they still can get fees from. Trust me when I say that Apple will NEVER submit to this legislation, they will find every sort of obscure or arcane tricks to comply with it without actually doing it. It would set a precedent that legislating can change Apple's behaviour, which they clearly do…
They already use USB-C on macs and iPads. The only practical reason for Lightning to survive is existing iPhone accessories. It could have been on the way out even before this. Not sure the fight is worth picking.
Do you have any vague idea how much money Apple makes from Lightning accessories? Every single thing that wants to use Lightning has to pay an Apple tax, and go through an incredibly cumbersome and expensive certification process. Letting that slip away from Apple's control means they lose a bit of control on their walled garden.
Meanwhile, MagSafe is also an environment for accessories they can control, and they can use as a way to extort fees from accessory developers. Apple has only one goal in mind - their margins. Everything they do must be seen in function of that. It's clear Apple is going to remove every single port from the iPhone, they only have to find how.