Eric Naslund's answer reminded me of a formula I once sort-of intuited (see comments), and eventually generalized, of which this is a special case. From what I've read it seems to be a standard heuristic in analytic number theory. I'll start with a preliminary:
$\rm\bf Definition$. Let $f$ be an arithmetic function. Then define the asymptotic average $\mathbb{E}(f)=\lim_{n\to\infty} \frac{1}{n}\sum_{m=1}^nf(m).$
The main result in question is one that generalizes the two mentioned formulas:
$\rm\bf Theorem$. Suppose $f$ is multiplicative and its asymptotic average exists. Then $\mathbb{E}(f)=\prod_{p}\left(1-\frac{1}{p}\right)\left(\sum_{r=0}^\infty \frac{f(p^r)}{p^r}\right). \tag{1}$
And finally, what I can think of right now for a derivation:
$\rm\bf Justification$. Define $f_x(n)$ to be $f(n')$, where $n'$ is $n$ but with all factors $q^r$ such that $q>x$ taken out of its prime factorization. Now note the proportion of naturals $n$ such that $p^r\|n$ (i.e. $p^r|n$ but $p^{r+1}\not|n$) is $(1-1/p)p^{-r}$: we find this by multiplying the probability a natural is not divisible by $p$ with the probability it is divisible by $p^r$. Then we find $f_x$'s asymptotic average via $\mathbb{E}(f_x)=\sum_{p|n\Rightarrow p\le x} f(n)\left[\prod_{p|n,\;p^r\|n}\left(1-\frac{1}{p}\right)\frac{1}{p^r}\right] \tag{2}$ $=\prod_{p\le x}\left[\left(1-\frac{1}{p}\right)\sum_{r=0}^\infty\frac{f(p^r)}{p^r}\right]. \tag{3}$ Now take the limit as $x\to\infty$ and we obtain the theorem.
There's a bit of bookkeeping to do, namely showing the decomposition of $\mathbb{E}(f_x)$ in $(2)$ is valid and that $\lim_{x\to\infty}\mathbb{E}(f-f_x)=0$ so that taking the limit is justified. And finally the answer to this question may be computed using this by letting $f$ be the multiplicative function such that $f(p^r)$ for a prime power $p^r$ is $1$ if $r$ is a perfect square and $0$ otherwise.