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?
Every function with compact support vanishes at infinity; this is what the Wikipedia article states. The converse is not true, as illustrated by your example.