How to reproduce
Increase the player's entity interaction range
/attribute @p generic.entity_interaction_range base set 64
❌ Try to hit a mob from far away and notice that it doesn't work
Increase the player's block interaction range
/attribute @p generic.block_interaction_range base set 64
Now you can hit mobs from far away
Can confirm.