A mosquito is walking at random on the nonnegative number line. She starts at $1$. When she is at $0$, she always takes a step $1$ unit to the right, but, from any positive position on the line, she randomly moves left or right $1$ unit with equal probability.What is the expected number of times the mosquito will visit $0$ before the first time she visits $4$?
I know that, if the mosquito is sitting at 1, then they have a 3/4 probability of ending at 0.
Then after the mosquito goes to $0$, the mosquito must immediately go back to $1$ next move, i.e. the whole situation restarts.
Consider the case that when the mosquito goes from $1$ to $4$ without passing $0$ as a success, and the case when the mosquito goes from $1$ to $0$ without passing $4$ as a failure. You already calculated the two probabilities as $$P(\text{success}) = \frac14,\quad P(\text{failure}) = \frac34.$$
Compare this with throwing a tetrahedral fair die repeatedly. What is the expected trials you throw $1$ to $3$ (a failure) before getting a $4$ (a success)? Hint: this is geometric distribution.
The expected count of failures, $X$, can be found in terms of success probability $p$ as $$E[X] = \sum_{x=0}^{+\infty}x\left(1-p\right)^xp$$ Looking up the closed form on Wikipedia, $$E[X] = \frac{1-p}{p}$$