I have a little problem there: If I want to build blocks I don't have to hold down and can dismantle blocks until I right-click again.
Reset Minecraft controls?
You don't use an autoclicker, do you?
In the accessibility settings there's that for snaking and sprinting, is that there too? I'm not sure right now
Sounds more like autoclicker in my opinion😅 Otherwise you have to look in the settings to see how the dismantle button is on you and possibly change.
If necessary, you could download and enter one of the oldest versions of Minecraft via the Minecraft Louncher. This will delete all your settings (because they didn't exist at the time) and you can switch back to the current version with the standard settings.
Maybe your mouse button is stuck?