You mention Euler's theorem in the title of the question; maybe you're not familiar entirely with what it says, but it gives exactly what you're looking for (Wikipedia article).
Euler's theorem: For any natural number $m$ and integer $a$ with $\gcd(a,m)=1$, $a^{\varphi(m)}\equiv 1\bmod m$.
When $m=pq$ for distinct prime numbers $p$ and $q$, we have $\varphi(m)=\varphi(pq)=(p-1)(q-1)$, and also $\gcd(a,m)=\gcd(a,pq)=1$ is true precisely when $a$ is not a multiple of either $p$ or $q$.
Euler's theorem works perfectly well when $m$ is not a product of distinct primes, but the totient function $\varphi$ just acts differently. For example, if $m=p^2$ for some prime $p$ (i.e., a product of primes that are not distinct), then $\varphi(m)=\varphi(p^2)=p(p-1)$, and the result is that for integers $a$ with $\gcd(a,m)=\gcd(a,p^2)=1$, we have $a^{p(p-1)}\equiv 1\bmod p^2$.