mediation analysis follows a set of cause and effect relationships. you need to clearly identify the independent, dependent and mediating variables. In order to find out the confounding variables, you must do the detailed review of literature about dependent and independent variables to identify all such variables that may affect the both and then control them during the mediation analysis.