Each user gets only one vote per post. That vote can be either up or down.
So, if you upvote a post, then downvote that same post, the system converts (i.e., changes) your original upvote into a downvote on that post. The same would be true if you downvoted and then upvoted a post: the system would convert your original downvote into an upvote, leaving only an upvote from you on that post.
You can also retract your vote by attempting to redo the same type of vote that you originally cast. So, say you upvoted a post because it looked superficially good, but then you realized that it was generated by an AI, which is not allowed. You could retract your upvote by clicking again on the upvote button. This would cause the system to remove your upvote. Remember that a user cannot vote on a post twice, so clicking the upvote button a second time doesn't cast a second upvote; it undoes the original. This is how you would retract a vote without switching your vote to the opposite type of vote.
There is one additional complication: in order to limit a relatively obscure abuse mechanism called "tactical voting", the system is currently designed to lock in your vote after a particular period of time (i.e., after a grace period). I won't get into what exactly tactical voting is here because it is not germane to understanding how the voting system works. The point is merely that you only have a certain grace period (currently set to 5 minutes) within which you are able to either undo (retract) or change your vote on a particular post. After that grace period expires, your vote is locked in, so you cannot change it. (If the post is edited by anyone, the lock-in no longer applies, and you can then change or remove your vote on that post.)
"Serial up/downvoting" is something else entirely. This is when one user goes through and casts a large number of votes on different posts in rapid succession. This is often done when targeting posts from a particular user, but it could also just be done indiscriminately. Basically, it's when you're thoughtlessly voting on posts without reading or evaluating them. There are system processes to automatically revert these types of votes, based on a variety of heuristics (which we do not disclose the details of in order to reduce the opportunity for folks to game the system). This system does work, but it is imperfect, so if it doesn't work for you, then you can raise a moderator flag on one of your posts (any one will do) to explain the issue and ask that the targeted votes be investigated and removed as appropriate. Note that the script that automatically reverts these only runs every 24 hours (generally at a particular time each UTC day), so you should wait a full 24 hours to give it the opportunity to work before raising a moderator flag. For more information on serial voting, see here: What can I do about getting a sudden flood of revenge downvotes?