Why does it work this way? Well the simplest answer is (as my old Computing teacher used to unhelpfully say):
It Just Does.
The reputation system is designed in such a way that any reputation received after hitting the repcap isn't counted (the same occurs if you are on a reputation of 1 and receive several downvotes followed by an upvote), although as soon as you're within the rep boundries again for that day then subsequent votes will again be counted.
Many similar questions have been raised on Meta StackOverflow over the years (as this is a StackExchange-wide issue not just a UX.SE one then you're more likely to get better answers over there), such as the following:
I think this is best summed up by Jon Skeet:
I don't know whether it "counts" for badge and rep report purposes... but you will lose the 2 rep. Of course, it only takes one upvote to get you back on track, even if you've had up to 5 downvotes. But it sucks for the last vote of the day to be a downvote...
There is an option available once a day to recalculate your reputation, although really that is only going to effect you if your reputation has been impacted by deleted posts. The option is here: https://ux.stackexchange.com/reputation but, as I say, it's manual, can only be run once a day, and probably won't address the particular issue.