"and so that he not turn aside from the mitzvah": even a "slight" mitzvah of a prophet. And thus is it written (I Samuel 13:13) "And Samuel said to Saul: You have acted foolishly. You have not kept the mitzvah, etc." "and so that he not turn aside from the mitzvah, right or left": even if he (seems to be) told that right is left and left is right.
"so that he prolong his days in his kingdom": If he does as is written here, he will be worthy of prolonging days in his kingdom.
"he and his sons": If he dies, his son succeeds him. This tells me only of a king. Whence do I derive (the same for) all of Israel's leaders? From "he and his sons in the midst of Israel" — All who are "in the midst of Israel" are succeeded by their sons.