Why do functions with compact support include those that vanish at infinity?

The support of a function is defined in Wikipedia as "the set of points where the function is not zero-valued, or the closure of that set".

Functions with compact support in $X$ are defined in Wikipedia as "those with support that is a compact subset of $X$. For example, if $X$ is the real line, they are functions of bounded support and therefore vanish at infinity (and negative infinity)".

Why functions vanishing at infinity are considered as having compact support?

An example of a function vanishing at infinity is $f(x) = \frac{1}{x^2+1}$, it's support is $\mathbb{R}$.

The compactness of a subset $K$ is defined as "every arbitrary collection of open subsets of $X$ such that covers $K$, there is a finite subset also covers $K$".

Now $\mathbb{R}$ is not compact, we can't say $f(x) = \frac{1}{x^2+1}$ has a compact support, am I right there?

You have the implication the wrong way round: $f$ compactly supported implies that $f$ vanishes at infinity. Vanishing at infinity is a necessary but not sufficient condition for a function to be compactly supported.
Since you are talking about functions on $\mathbb{R}$ and infinity is not actually an element of the reals, “vanish at infinity” is always only defined in a limit sense. Now you might say this requires the statement to be “continuous functions with compact support include those that vanish at $\infty$” – however, since all $K$-supported functions are actually constant outside of $K$, they are trivially continuous there1, and the limit is, like all those function values, zero.