As mentioned in the edit, this can be represented as a Markov chain - in particular, a discrete time Markov chain on a finite state space, which is absorbing.
For much of the answer below, my reference is "Grinstead and Snell's Introduction to Probability", currently located at this link https://math.dartmouth.edu/~prob/prob/prob.pdf
For such a Markov chain, the states which are not absorbing are called transient. If there are $t$ transient states (for the posted problem, $t=N^2 - m$) and $r$ absorbing states (for the posted problem, $r=m$), it is common to order the states so that the transient states are first, so that the probability transition matrix is in block form as:
$$
P = \begin{bmatrix} Q & R\\ 0 & I_r \end{bmatrix}
$$
Here $Q$ is $t \times t$, $R$ is $t \times r$, $0$ is the $r \times t$ zero matrix, and $I_r$ is the $r \times r$ identity matrix.
It is known that the $i,j$ entry of the "fundamental" matrix $N = (I_t - Q)^{-1}$ is the expected number of times that the chain will visit transient state $j$ if it started in transient state $i$.
Therefore, the sum of the $i^\mathrm{th}$ row of $N$ is the expected number of steps before being absorbed, if starting in transient state $i$.
The probability of being absorbed into absorbing state $j$, $1\le j \le r$, if the chain started in transient state $i$, is the $i,j$ entry of $B = NR$.
As for "the expected number of steps for each barrier", if the chain starts in a transient state $i$ that has a nonzero probability of not hitting a particular absorbing state $j$, then I believe the interpretation of the "expected number of steps to hit that barrier" would be infinity, since there is a positive probability that it will never hit the barrier.
But, if we are conditioning on the event that the chain is absorbed into barrier $j$, starting from state $i$, then to find the "expected number of steps before being absorbed", you proceed as above with two modifications:
First, you would consider a chain of only the transient states with positive probability of being absorbed into absorbing state $j$, together with absorbing state $j$ (so $r=1$). Any transient states that could not be absorbed into absorbing state $j$ (such as a transient state surround by other barriers) would not be a part of this new chain. Neither would the other absorbing states.
Second, you would use conditional probabilities in your probability transition matrix for this chain, so that the rows still sum to one. For example, if a state used to have four neighbors, but one of them was a barrier that we know it doesn't transition to (since it eventually gets absorbed into a different barrier), then the conditional probability that the random walk transitions to each of those three remaining neighbors is $\frac{1}{3}$.
Then you would have
$$P' = \begin{bmatrix} Q' & R'\\ 0 & 1 \end{bmatrix}$$
You would solve for $N' = (I - Q')^{-1}$, and the expected number of steps before being absorbed, starting from transient state $i$, is the sum of the $i^\mathrm{th}$ row of $N'$.
Best Answer
Look at my comment under
This problem can be decomposed as several mini problems. Each of these mini problems are versions of a common expected value problem which looks something like a line of lily pads numbered $0,1,\ldots n$ with a frog starting on $k\in (0,n]$ and something bad (like a crocodile) on lilypad $0$ and something good (like food) on lilypad $n$.
Let's call the expected value of the number of steps it takes the frog to reach $n$ when starting from $k$ as $E(k,n)$. We get the following system of equations using states (assuming $n\geq 2$) $$\begin{cases} E(1,n)=1+E(2,n)\\ E(x,n)=1+\frac{1}{2}E(x-1,n)+\frac{1}{2}E(x+1,n)~\forall x\in [2,n-1]\\ E(n,n)=0\end{cases}$$
We can see that $E(x,n)$ has a really nice recursion for the non-edge cases (if $a_x=E(x,n)$, then $a_x-3a_{x-1}+3a_{x-2}-a_{x-3}=0$) We also have $3$ "initial" conditions ($E(1,n)=1+\frac{1}{2}E(2,n)$, $E(n,n)=0$, and $2E(x,n)-E(x-1,n)-E(x+1,n)=2$). We can use the properties of linear recurrences to conclude that $E(x,n)$ will be some quadratic polynomial in $x$. Let's say $E(x,n)=ax^2+bx+c$ (the constants $a,b,c$ will likely be dependent on $n$).
From the recursion, we have that $$2E(x,n)-E(x-1,n)-E(x+1,n)=2$$ $$(E(x,n)-E(x-1,n))-(E(x+1,n)-E(x,n))=2$$ $$(2ax+b-1)-(2ax+2a+b-1)=2$$ $$-2a=2$$ $$a=-1$$ So $E(x,n)=-x^2+bx+c$. Now we also have $$\begin{cases} E(1,n)=1+E(2,n)\\E(n,n)=0\end{cases}$$ $$\begin{cases} -1+b+c=1+(-4+2b+c)\\-n^2+bn+c=0\end{cases}$$ $$\begin{cases} b=2\\c=n^2-bn\end{cases}$$ $$\begin{cases} b=2\\c=n^2-2n\end{cases}$$ Hence, we have $\boxed{E(x,n)=-x^2+2x+n^2-2n}$. This result will be useful for the rest of the problem
There is also another problem we need to solve that will be useful. This is the probability that given lilypads numbered $0,1,\ldots n$ with a frog at $x$, what is the probability that they will go to $n$ before going to $0$. If we call this probability $P(x,n)$, we get a similar system of equations using states (assuming $n\geq 2$) $$\begin{cases} P(0,n)=0\\ P(x,n)=\frac{1}{2}P(x-1,n)+\frac{1}{2}P(x+1,n)~\forall x\in [1,n-1]\\ P(n,n)=1\end{cases}$$ Using a similar approach as previously, we can use the fact that there is a nice recursion for $P(x,n)$ to see that $P(x,n)$ must be a linear polynomial in $x$. Hence, we have $P(x,n)=ax+b$ Since $P(0,n)=0$ and $P(n,n)=1$, we can quickly see that $\boxed{P(x,n)=\frac{x}{n}}$.
Back to the original problem, to finish on $3$, you must first get to $2$ or $4$. Then you must go to the other of $2$ or $4$. Then you must go to $3$.
The only decision we have to make is whether to go to $2$ or $4$ first. After we have made this decision, there are no more decisions left to make so that we achieve our goal of finishing on $3$
Let's say that we choose to go to $2$ before going to $4$. We can treat $4$ as the $0$ lilypad and $2$ as the $n$ lilypad. The probability that we actually choose this path of going to $2$ before going to $4$ is $P(2,3)$. The expected number of steps to get to $2$ is $E(2,3)$.
From there, we must go to $4$ without going to $3$. The expected number of steps to do that is $E(1,4)$. From there we simply need to go to $3$ anyway possible. We can't actually use any of the formulae we derived above, but this is a straightforward application of states with a lot of symmetry. So I'll leave it as an exercise to the reader to prove that the expected number of steps to do this is $4$.
Now we deal with the case that we choose to go to $4$ before going to $2$. We can treat $2$ as the $0$ lilypad and $4$ as the $n$ lilypad. The probability that we actually choose this path of going to $4$ before going to $2$ is $P(1,3)$. The expected number of steps to get to $4$ is $E(1,3)$.
From there, we must go to $2$ without going to $3$. The expected number of steps to do that is $E(1,4)$. From there we simply need to go to $3$ anyway possible. As before, the expected number of steps to do this is $4$.
In total, the expected number of steps to execute this 2-part procedure is $$P(2,3)(E(2,3)+E(1,4)+4)+P(1,3)(E(1,3)+E(1,4)+4)$$ $$=\frac{2}{3}(3+9+4)+\frac{1}{3}(4+9+4)$$ $$=\frac{32}{3}+5$$ $$=\frac{47}{3}$$
Similarly, it's not hard to see that the probability you end on $3$ is $$P(2,3)P(1,4)(1)+P(1,3)P(1,4)(1)$$ $$=P(1,4)(P(2,3)+P(1,3))$$ $$=\frac{1}{4}$$
Code for finding expected number of steps to end on 3. Should return approximately 11 if trials is high enough
Code for finding $E(x,n)$