Define the function $f : \mathbb{R}^2 \to \mathbb{R}$ as $$f(x)= \begin{cases} \ \ 1, \ \text{if} \ x\ge 0 \, \text{ and} \,x \le y\le x+1\\ -1, \ \text{if} \ x\ge 0 \, \text{and} \,x+1 \le y< x+2 \\ \ \ 0, \ \text{otherwise} \end{cases}$$ Let $\mathcal{M}$ be the Lebesgue $\sigma$-algebra on $\mathbb{R}$ , show that $f$ is $\mathcal{M}\times \mathcal{M}$ measurable and $\int_\mathbb{R} \int_\mathbb{R} f(x,y) \,d m(x) \,d m(y) \neq \int_\mathbb{R} \int_\mathbb{R} f(x,y) \,m(dy)\,m(dx)$.
We can write $f(x,y) = \chi_{[0,\infty)\times (x,x+1)} - \chi_{[0,\infty) \times (x+1,x+2)}$ and since both characteristic functions are measurable, we get that $f$ is measurable. I could not calculate $\int_\mathbb{R} \int_\mathbb{R} f(x,y) \,d m(x) \,d m(y)$
$\int_\mathbb{R} (\int_\mathbb{R} f(x,y) \,d m(y)) \,d m(x)=\int_\mathbb{R} (\int_\mathbb{R} (\chi_{[0,\infty)\times (x,x+1)} - \chi_{[0,\infty) \times (x+1,x+2)}) \,d m(y)) \,d m(x)=\int_\mathbb{R} ((m([x+1,x+2])-m([x,x+1])) \,d m(x)=\int_\mathbb{R} (\int_\mathbb{R} (0) \,d m(x)=0$
whereas,
$\int_\mathbb{R} (\int_\mathbb{R} f(x,y) \,d m(x))\,d m(y)=\int_{0}^{1}\left ( \int_{\mathbb R}f(x,y)dm(x) \right )dm(y)+\int_{1}^{2}\left ( \int_{\mathbb R}f(x,y)dm(x) \right )dm(y)+\int^{\infty}_{2}\left ( \int_{\mathbb R}f(x,y)dm(x) \right )dm(y)=1$
because the last of the these is $0$ and as for the first two, we have
$\int_{0}^{1}\left ( \int_{\mathbb R}f(x,y)dm(x) \right )dm(y)=\int_{0}^{1}\left ( \int_{\mathbb R}(\chi_{[0,\infty)\times (x,x+1)} - \chi_{[0,\infty) \times (x+1,x+2)})dm(x) \right )dm(y)=\int_{0}^{1}ydm(y)=1/2.$
$\int_{1}^{2}\left ( \int_{\mathbb R}f(x,y)dm(x) \right )dm(y)=\int_{1}^{2}\left ( \int_{\mathbb R}(\chi_{[0,\infty)\times (x,x+1)} - \chi_{[0,\infty) \times (x+1,x+2)})dm(x) \right )dm(y)=\int_{1}^{2}\left ( \int_{\mathbb R}(y-(y-1) - (y-1)dm(x) \right )dm(y)=1/2.$