People frequently see in others the faults that they have themselves. He accuses you of that because that is his own problem, that he is familiar with, and therefore he projects it onto others whenever there is the slightest hint of it that turns his thinking in that direction.
I have seen this so frequently that I actually think it is a defensive tactic of sorts - subconscious probably rather than intentional. Because if you accuse somebody of something, and they come back and say "actually, it's you that's like that", it sounds like they're just making up an unfair counter-accusation, so you cut off their argument at the foot. That might be hard to follow, so I'll give an illustration.
Bill has an obvious, central character flaw causing a problem - let's say he has a tendency to personalise arguments and make personal attacks instead of discussing the actual matter at hand. Bill has often done this and Bob knows it.
Bill is arguing with Bob about something. Bill criticised Bob, then Bob criticised Bill.
Bill, being familiar with personal attacks and sensitive to them, immediately interprets Bob's statement as a serious personal insult, and accuses Bob of 'always' making personal attacks against others.
Bill has pointed out the speck in Bob's eye (Bob is not flawless), ignoring the log in his own. But in this case, it is a strategic move that places Bob in a difficult position. How can Bob respond?
- If he responds in a factually correct way, he could point out the log in Bill's eye and argue that it's worse than his own problem ("Actually Bill, you're the one always making personal accusations"). But then it sounds like he's the one ignoring his own character flaws. It also sounds like he just invented this accusation because Bill said it about him. And it's a further escalation of the argument.
- But if he ignores this central issue and makes a peripheral point (e.g. defensively tries to explain away his own statement as not a personal attack, or criticises Bill for a different matter), he is ignoring the fundamental problem, being intellectually dishonest, and knows the discussion will achieve nothing positive. So again it's a further escalation of the argument.
Bill's accusation is therefore a pre-emptive defence - it has put Bob in an awkward position where he cannot make points he believes is truthful without coming across badly and making Bill himself look like the victim.
I don't think anybody really goes through all this logic and does this intentionally. But I do commonly see people accusing others of the faults they themselves obviously exhibit. Likely we learn on some subconscious level that this argument method causes us to win arguments more frequently, so we automatically adopt it without really knowing or caring why it is successful, it just becomes instinctual.