They did it by excelling in the Europa and Conference Leagues. For better or worse, UEFA is rewarding countries for their collective performances.
Where it gets dicey for me is that they give nearly equal weight between the three competitions. Spain’s coefficient was damaged because they were too good in the Champions League. They would’ve been better off having a couple of their teams underperform in the Champions League and then make a deep run in the lower tournaments. But instead they progressed to the UCL knockout rounds and weren’t able to earn as many points because they obviously played more difficult opponents.
The Champions League should be awarded double the points of the Conference League, not the same. And the Europa League points would be right between.