The charge attack of spears has inconsistent hit registration. Even when attacking the same target at sprinting speed with the same camera angle, occasionally charge attacks will deal no knockback but still deal damage, and occasionally they will deal no damage but still deal knockback (which shouldn’t be possible as minimum required speed for damage is 4.6 while the knockback is higher at 5.1). Note that the dealing knockback but no damage case is now much less common in 25w42a, but can still happen.
With stationary (knockback resistant) and No:AI entities, this issue is exaggerated, with attacks occasionally not connecting at all (note that this is different to a stationary but still moveable target, like a mannequin). In this case, the hit sound of the charge attack still plays, even though the hit does not register correctly.
This bug can also be used against the ender dragon, where velocity can be stored by repeatedly attacking it with a knockback sword, and then holding a spear charge attack to one shot the dragon using the stored velocity (see the attached comment by Kolleen).
This is because the NoAI entities have velocity but don’t move. You can try /data get entity xxx Motion