A confounding variable must:
- Be independently associated with the outcome;
- Be associated with the exposure
- Must not lie on the causal pathway between exposure and outcome.
These are the criteria for considering a variable as a potential confounding variable. If the potential confounder is discovered (through stratification and adjustment testing) to actually confound the relation between risk and outcome, then any unadjusted association seen between risk and outcome is an artifact of the confounder and hence not a real effect.
An effect modifier on the other hand does not confound. If an effect is real but the magnitude of the effect is different depending on some variable X, then that variable X is an effect modifier.
To answer your question therefore it is to my understanding not possible to have a variable that acts as both an effect modifier and a confounding variable for a given study sample and a given pair of risk factors and outcomes.
You can find more information here