For $x,y \in \mathbb{R}$, function $f(x,y)$ is defined as $$f(x,y) = 1 \quad\textrm{if}\quad x=y$$ $$f(x,y) = 0 \quad\textrm{if}\quad x\neq y$$
It seems to me that the integral $I = \int_0^1 \int_0^1 f(x,y) dxdy$ should equal to the diagonal of the unit square, hence $$I = \int_0^1 \int_0^1 f(x,y) dxdy = \sqrt{2} \tag{1}$$
However, in writing the integral mathematically, I got $$I = \int_0^1 \int_0^1 f(x,y) dxdy= \int_0^1 1 dx = 1 \tag{2}$$
Could anyone please show me where I was wrong in (1) and/or (2)?
Not sure how you think in (1) but (2) is the correct answer.
Imagine the x- and y-axes and that you start in the origin (0,0). Now do the integral of your function over dx i.e. move over the x-axis from (0,0) to (1,0). The only time your integral is not zero is when x=y=0, you get that the first integral is equal to 1 and you have ended up at the point (1,0). Now do the integral over dy. You move from (1,0) to (1,1) and your integral will only be non-zero were x=y=1 and the second integral is thus also equal to 1 and the entire two dimensional integral is therefore one.
Hope this helps!