Which version are you in?
What item are you holding when you activate the command block?
It looks like you are trying to enchant an item that can't have the sharpness enchantment.
In 1.19.4 if I put the following command into a command block and activate it while holding a sword then it works:
enchant @p sharpness 1
1