Let's take this one first: Can she appeal?
No. When your friend was removed, she was served with a removal notice at the port, this explains the reason(s) for the removal and whether or not there is recourse for their decision. Since she arrived on a visit visa, she has no recourse (including appeal).
We can't understand whether this is right.
When your friend applied for their entry clearance, she signed a binding agreement with the UK government and part of the agreement says...
I must inform the UK diplomatic mission if there is a material change
to my circumstances, or any new information to my application becomes
When somebody goes from 3 weeks to 5 months, that's material. Big time material. Visitors from Kenya only do that in the most extreme circumstances because they have ties to Kenya that prevent them from it. Your friend had an obligation to inform them that her circumstances had changed and (apparently) defaulted on it.
When they see things like that, the IO will normally refer to another part of the agreement your friend signed and wonder if they are in breach of this clause also. It says...
That the information given on this form whether input by myself, input
on my behalf by a third party or automatically pre-populated is
complete and correct to the best of my knowledge and belief.
The IO would be entitled to suspect that other information your friend provided on the premise of their visit was either false or misleading. At that point the sole factor preventing your friend's removal was her articulation skills and personal impact. She likely failed in those areas because she was not accustomed to the IO's personal impact and interview training.
So whether it is "right or not" is a philosophical question and beside the point. It's legal for them to do that.
When somebody is refused entry clearance we normally need to see the text of the refusal notice because it contains speed codes and formulae which are helpful in understanding what caused the refusal. But when somebody is removed, there are only about two or three reasons for it, and they are not nuanced in the same way that refusals are. The exact reason(s) are listed on the removal notice, but based upon everything you wrote, I am pretty sure it is under Paragraph 321A, which says...
(i) False representations were made or false documents or information
were submitted (whether or not material to the application, and
whether or not to the holder's knowledge), or material facts were not
disclosed, in relation to the application for entry clearance; or in
order to obtain documents from the Secretary of State or a third party
required in support of the application.
(ii) a change of circumstances since it was issued has removed the
basis of the holder's claim to admission, except where the change of
circumstances amounts solely to the person becoming over age for entry
in one of the categories contained in paragraphs 296-316 of these
Rules since the issue of the entry clearance;
With the primary emphasis on "change of circumstances", which does not attract a ban like the "deceptive" one does.
Other answers to your question have focused on the landing interview and suggested or implied that your friend should have used silence as her interview strategy. I don't think the landing interview had a lot to do with it. If he thought that she were being honest or innocently naive, the IO had the option of curtailing her entry clearance to 3 weeks and letting her enter, but he chose to remove her instead. So I would guess that she was flagged up beforehand. Somebody in Kenya shopped her (i.e., betrayed her, informed on her), or her luggage had too many pieces or weighed too much for 3 weeks, or her account had a strange deposit after the decision was issued, or she had told too many people about her plans (or WORSE, you told too many people and got shopped that way). But that's only a guess. Regardless of how they found out, it's fortunate that she got removed; if she was caught on exit she would never be back.