If you find an answer to be incorrect, you should probably downvote it, so that other users know that it either didn't work or perhaps has some terrible side effect like a security vulnerability, or running out of memory.
The gray line of when to and when not to downvote answers is a very long discussion, so I am not really going to get into the nuance of it, please look around here and on Meta Stack Exchange for that history; bring a good drink.
However, one thing is very straightforward: the platform (Stack Overflow) will not determine what should and should not be downvoted for you. This means, as you found out, that it is possible to downvote an accepted answer; it also means it is possible to upvote a highly downvoted answer. As far as accepted answers go, in general that just means that answer is the one which the question asker felt solved the problem best for them; different answers may work better than that for your situation (or theirs), and while rare there are inaccurate or just plain dangerous accepted answers on Stack Overflow.
As for your exact situation, let's just assume the post was at +10 / -0, a net of +10. When you downvoted it, it became +10 / -1, a net of +9. When you upvoted it after downvoting, it removed your downvote, and gave an upvote, creating +11 / -0. This may seem to have changed the post with two upvotes from 9 to 11, but in reality, it was just the effect of removing your downvote and adding an upvote. Keep in mind, there is a 5 minute window for changing votes after casting them (unless the post is subsequently edited in which case you may then change it at any time following the edit).