Find necessary and sufficient conditions on $a,b\in\Bbb R$ such that the following matrices have the same rank:
$$\begin{pmatrix} a&b\\ b&a \end{pmatrix} ,\begin{pmatrix} 0&1\\ 1&2\\ 3&4 \end{pmatrix}$$
So the question is when will the matrix $$\begin{pmatrix} a&b\\ b&a \end{pmatrix}$$ have rank $2$.
Multiplying the first row by $(-\frac{b}{a}), a\neq 0, b\neq 0$ and adding it to the second one gives us: $$\begin{pmatrix} a&b\\ b&a \end{pmatrix}\sim\begin{pmatrix} a&b\\ 0&\frac{a^2-b^2}{a} \end{pmatrix}$$
Now it must be true $a^2-b^2\neq0\Rightarrow a\neq -b \land a\neq b$
So is $a\neq -b \land a\neq b$ the necessary and sufficient condition?
$$A :=\begin{pmatrix} a&b\\ b&a \end{pmatrix}$$
If we write $rank(A) =: r(A)$, we can rewrite your question as this: "When is $r(A) = 2$?".
In other words, as $A \in M_{2,2}(\Bbb R)$, we are asking ourselves when $A$ has full rank, i.e. when every row or column of $A$ is linearly independent from the others; a nice way to see this is to verify when $det(A)\neq0$; in fact the equivalence $det(A) \neq0 \Leftrightarrow r(A) = 2$ is trivial.
In our case $det(A) = a^2-b^2 \neq0 \Leftrightarrow a^2 \neq b^2 \Leftrightarrow abs(a) \neq abs(b)$, otherwise written as $|a| \neq |b|$, or $a \neq \pm b$.
So this is a necessary and sufficient condition.
Attention: If you multiply by $\left( -\frac b a \right)$ you require $a \neq0$, but $0$ is a valid value of $a$ if $b \neq0$.