A Markov chain on state space {1,2,3,4,5} has transition matrix

The process starts in state 1.

d) Calculate the expectation of the number of visits to state 2 before absorption.

Solution:

I am not sure how to get the above three equation? can you help please?

These are easily solved to give