I recommend reading more about multivariate analysis, specifically multivariate multiple regression. "multivariate" means multiple dependent variables. "multiple regression" means that there are multiple independent variables. When models are fit in this context, you will see that the parameter estimates account for the covariance between the dependent variables. See this for an introduction with R. A super-simple example is below:
mlm1 <- lm(cbind(mpg, hp) ~ cyl + disp + wt + vs, data = mtcars)
summary(mlm1)
vcov(mlm1)
EDIT: Update with additional explanation
The question assumed "Now consider a situation in which, for some logical reason, the experimenter may want to assess if the two effects are associated, hypothesizing that the second one may depend on the first one". This is what leads to multivariate regression. $Y_1$ depends on $X_1$, $Y_2$ depends on $X_2$, and they may depend on each other. That dependency shows up in the form of a correlation between $Y_1$ and $Y_2$ and some interdependency on the $X_1$ and $X_2$ independent variables. Multivariate models can include interactions.
Alternate Answer
It is also possible that what is meant by the question is a causal mediation model where $X_2$ and $Y_1$ are causal mediators. using the original $Y_1, Y_2, X_2, X_1$ notation:
$Y_1 = \beta_{10} + \beta_{11} X_1$
$X_2 = \beta_{20} + \beta_{21} Y_1 + \beta_{22} X_1$
$Y_2 = \beta_{30} + \beta_{31} X_2 + \beta_{32} Y_1 + \beta_{33} X_1$
I recommend fitting this with MCMC using Stan.