This applies whether you have a closer connection to a foreign country than [to] the United States during 2018, and whether you are a resident under the substantial presence test or green card test.
Unlike the other answerers so far, I would call this sentence ungrammatical.
The word "whether" generally requires an alternative, such as "or not." The second half of the example sentence does provide such an alternative for its "whether," so my only objection to that half is the faulty parallelism. IMO it should have been written grammatically as
... and whether you are a resident under the substantial presence test or under the green card test.
(That is, maybe you're a resident under the substantial presence test, or maybe under the green card test; but it doesn't matter; the rule applies no matter which is the case.)
However, the first half of the example sentence has a "whether" without an "or not." Therefore it's just as ungrammatical as if you wrote a "both" without an "and":
This applies *both if you have a closer connection to a foreign country than to the United States during 2018.
Two grammatical possibilities for this sentence would be:
This applies whether you have a closer connection to a foreign country than to the United States during 2018 or not.
This applies whether or not you have a closer connection to a foreign country than to the United States during 2018.
Since you saw this in an official government publication, I'm sure they meant "whether or not," and it was a simple typo. However, if you had seen this misuse of the word "whether" in a news article online, there would be another highly probable explanation. Many third-party news aggregators recycle content scraped from other sites after running it through a "thesaurus app" to disguise the plagiarism. (For example, see how many news aggregators refer to Macaulay Culkin's role in House Alone.) So, if I saw the word "whether" used like this in an online news story, I would just assume that it had been spewed out by a thesaurus match on the word if.
If and whether are generally synonymous:
She asked if it was raining out.
She asked whether it was raining out.
In this particular sentence, though, the substitution takes us from grammatical (with one meaning) to ungrammatical (where the most natural "fix" has the completely opposite meaning).
This applies [only] if you have a closer connection to a foreign country than to the United States. [It applies in only one case.]
This applies *whether [or not] you have a closer connection to a foreign country than to the United States. [It applies in both cases.]
regardless
would definitely be clearer. I do agree that it is rather strange. One does understand nevertheless.