$X$ is a topological space throughout.
There are two standard definitions of a neighborhood. Both are used widely. The difference you are highlighting comes down to whether neighborhoods are defined to contain an open subset, or defined to be an open subset.
- For $x \in X$, $V \subset X$ is a neighborhood(1) of $x$ if $x \in U \subset V$ for some open set $U \subset X$. (note 1)
- For $x \in X$, $V \subset X$ is a neighborhood(2) of $x$ if $x \in V$ and $V$ is open. (note 2)
In the familiar setting $X = \mathbb{R}$, there are no neighborhood(2)s that are compact. However, for each $x \in X$, there are neighborhood(2)s, $V_x = (x-1/2, x+1/2)$, for instance, whose closure is closed and bounded, hence compact (by the Heine-Borel theorem). In this setting, the closures of the neighborhood(2)s are neighborhood(1)s, so we get these two characterizations:
- $\mathbb{R}$ is locally compact because every $x \in \mathbb{R}$ has a compact neighborhood(1).
- $\mathbb{R}$ is locally compact because every $x \in \mathbb{R}$ has a neighborhood(2) whose closure is compact.
(note 1): See, for instance, Bredon, Glen E., Topology and Geometry, ISBN ISBN 0-387-97926-3, p. 4: "If $X$ is a topological space and $x \in X$ then a set $N$ is called a neighborhood of $x$ in $X$ if there is an open set $U \subset N$ with $x \in U$."
(note 2): See, for instance, Munkres, James R., Topology: A First Course, ISBN 0-13-925495-1, p. 96: "Mathematicians often use some special terminology here. They shorten the statement '$U$ is an open set containing $x$' to the phrase '$U$ is a neighborhood of $x$.'" This language also appears in the second edition of this work, ISBN 978-0131816299, still p. 96. Alternatively, Kelley, John L., General Topology, ISBN 0-387-90125-6, p. 14: "A neighborhood of a point is any open set containing this point." Kelley then asserts that analysts and Bourbaki use "neighborhood" in the neighborhood(1) sense.