Proof that if $(X,Z)\stackrel{d}{=}(Y,Z)$ then $X\stackrel{d}{=}Y$ 
Let $X,Y,Z$ be random variables on $\Bbb{R}$ such that $(X,Z)\stackrel{d}{=}(Y,Z)$. I want to show that $X\stackrel{d}{=}Y$.

My idea was the following. Let me take any measurable $A\subset \Bbb{R}$ then $$\Bbb{P}(X\in A)=\Bbb{P}((X,Z)\in A\times \Bbb{R})\stackrel{*}{=}\Bbb{P}((Y,Z)\in A\times \Bbb{R})=\Bbb{P}(Y\in A)$$
Where in $*$ I used that $(X,Z)\stackrel{d}{=}(Y,Z)$.
Does this work? And if yes can this argument be generalized to random variables with values in an arbitrary space $E$?
 A: Yes this works. Except that you would not take any $A\subset\mathbb R$ but any measurable subset $A\subset\mathbb R$. And yes you can replace $\mathbb R$ with $E$ that is perfectly fine.
A: As an aside, you can also work with Characteristic functions like I mentioned in the comments.
The characteristic function $\psi_{\underline{X}}$ for a random vector $\underline{X}=(X_{1},...,X_{n})$ is defined to be $\psi_{\underline{X}}(t)=E[\exp(i\langle t,\underline{X}\rangle]$ . Note that $t\in\Bbb{R^n}$ and $\langle t,\underline{X}\rangle=\sum_{i=1}^{n}t_{i}X_{i}$ . And if $\psi_{\underline{X}}(t)=\psi_{\underline{Y}}(t)$ for all $t\in\Bbb{R}^{n}$ if and only if $\underline{X}\stackrel{d}{=}\underline{Y}$
Then if you pick $t=(0,0,...,t_{i},0,...0)$ such that $t_{i}\in\Bbb{R}$ then you recover the characteristic function for the rv $X_{i}$ .
So in your case , it suffices to show that since $(X,Z)\stackrel{d}{=}(Y,Z)$ , you have $\psi_{(X,Z)}((t_{1},0))=\psi_{(Y,Z)}((t_{1},0))$ for all $t_{1}\in\Bbb{R}$
But $\psi_{(X,Z)}((t_{1},0))=E[\exp it_{1}X]=\psi_{X}(t_{1})$
Thus $X$ and $Y$ have the same characteristic functions and have the same distribution.
As I said, you don't really need this to solve your problem but it is good if you know this technique comes in handy when you are dealing with Multivariate Gaussians for example. You see that actually calculating the probabilities by hand and showing equality is a painful task. It is easier to show equality of two functions. In case of multivariate Gaussians , you may only be told the covariance matrix and the sample mean. In that case , you can use this technique to show that if $Y$ has multivariate Gaussian distribution then $v^{T}Y$ has univariate Gaussian distribution for any vector $v$.
