Tax is written by a bunch of people whose background is overwhelmingly from law, not finance, for reasons that have nothing to do with logic, consistency, financial literacy, understanding, sanity, or common sense. Politicians frequently pass laws without understanding what it will do or what its implications are, because they just didn't think that far ahead. It is quite possibly the worst system you could come up with for writing tax law.
That said, there is a logic to most of it, but not in a way that allows you to come up with general heuristics or universal abstractions.
That said, there is a logic to most of it, but not in a way that allows you to come up with general heuristics or universal abstractions.