This question assumes the following definitions.
(1) $\quad\pi(x)==\sum\limits_{p\le x}1\qquad\text{(prime counting function where $p\in P$ is a prime})$
(2) $\quad\pi_2(x)==\sum\limits_{p_2\le x}1\qquad\text{(twin-prime counting function where $p_2\in P_2$ is a twin-prime)}$
(3) $\quad\pi_{sg}(x)==\sum\limits_{p_{sg}\le x}1\qquad\text{(Sophie Germain prime counting function where }\\$ $\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\text{$p_{sg}\in P_{sg}$ is a Sophie Germain prime)}$
(4) $\quad M(x)=\sum\limits_{n\le x}\mu[n]\qquad\text{(Mertens function)}$
I believe the prime counting functions defined in (1) to (3) above can be expressed in terms of Mertens function defined in (4) above as follows where
- $\nu(n)$ is the number of distinct primes $p$ dividing $n$,
- $\nu_2(n)$ is the number of distinct twin-primes $p_2$ dividing $n$, and
- $\nu_{sg}(n)$ is the number of distinct Sophie Germain primes $p_{sg}$ dividing $n$.
(5) $\quad\pi(x)==\sum\limits_{n\le x}\nu(n)\ M\left(\frac{x}{n}\right)$
(6) $\quad\pi_2(x)==\sum\limits_{n\le x}\nu_2(n)\ M\left(\frac{x}{n}\right)$
(7) $\quad\pi_{sg}(x)==\sum\limits_{n\le x}\nu_{sg}(n)\ M\left(\frac{x}{n}\right)$
Formulas (5) to (7) are related to the following more general conjectured relationship which I've tested on several additional functions over small ranges of $x$.
(8) $\quad f(x)=\sum\limits_{n\le x} a(n)=\sum\limits_{n\le x} b(n)\ M(\frac{x}{n})\,,\quad b(n)=\sum\limits_{k|n} a(n)$
Question: Can the conjectured relationship illustrated in (8) above be proven which would also imply the correctness of formulas (5) to (7) above?
Obviously, by the properties of generalized convolution, we have
$$ \sum_{n\le x}(f*g)(n)=\sum_{n\le x}f(n)\sum_{m\le x/n}g(m) $$
As a result
$$ \sum_{n\le x}b(n)M\left(\frac xn\right)=\sum_{n\le x}b(n)\sum_{m\le x/n}\mu(m)=\sum_{n\le x}(b*\mu)(n) $$
By the definition of $b(n)$ and the associativity and commutativity of Dirichlet convolution, we deduce
$$ (b*\mu)(n)=((1*a)*\mu)(n)=(a*(1*\mu))(n)=a(n) $$
Accordingly, your conjectured relationship is true.