For graphs $G, H$, let $G \times H$ denote the graph with vertex set $V(G) \times V(H)$ and such that $(g_0, h_0)$ and $(g_1, h_1)$ are connected by an edge iff $g_0$ and $g_1$ are connected by an edge and $h_0$ and $h_1$ are also connected by an edge. By construction this is the categorical product in the category of graphs we're considering, hence we have a natural isomorphism

$$\text{Hom}(X, G \times H) \cong \text{Hom}(X, G) \times \text{Hom}(X, H).$$

Now let $G$ be the disjoint union of countably many copies $Y_n, n \in \mathbb{N}$ of some auxiliary graph $Y$. I claim that $|\text{Hom}(X, G)|$ is always either empty or infinite, as follows: if $f : X \to G$ is a homomorphism, consider the embedding $[k] : G \to G$ which sends $Y_n$ to $Y_{n+k}$. Then the homomorphisms $[k] \circ f : X \to G$ are distinct for all $k$: they can be distinguished by the smallest index $j$ for which the image of the homomorphism intersects $Y_j$ (which is necessarily $k$ plus the corresponding index for $f$ itself).

Letting $H = G \times G$, and using the fact that infinite cardinalities are equal to their squares (unfortunately this is equivalent to the axiom of choice; probably this can be avoided by picking $H$ more carefully), we conclude that if we can find a graph $Y$ for which $G$ and $G \times G$ are not isomorphic, then we have constructed a counterexample.

We can take $Y$ to be the path graph $P_3$ on $3$ vertices. Then $H$ is the disjoint union of countably many copies of $Y \times Y$, which is a connected graph with $9$ vertices. Hence $G$ and $H$ have connected components of different cardinalities and are not isomorphic.

(The moral of the story is that two infinite cardinalities being equal is a much weaker condition than two finite cardinalities being equal.)