A: The mod variation accomplishes the effect using mixins. It does not replace the enchantment of infinity itself, rather it changes the game's mechanics as to account when the user has a projectile weapon enchanted with infinity. If another Data Pack or mod changes the infinity enchantment, the mod variation will still work.
The Data Pack variation, on the other hand, replaces the enchantment itself. This has only been possible with the advent of 1.21 and data-driven enchantments.