Finite Automaton that accepts only the words baa,ab, abb and no other strings longer or shorter

I understand where they got baa and ab but how did they get it to have abb ?

Just follow the arrows. "a" takes you to q1, then "b" takes you to q2, and another "b" takes you to q3, which is an accepting state.

this is confusing to me with having a q7 state here.

The q7 represents a failure state. Once the automaton enters that, it can't leave, so it will never accept that input string.


Expanding on Newb's point, you can think of Q7 as a 'trap' - the automaton can never escape, since both A and B lead back to Q7. It is necessary so that all strings are valid inputs to the FA, acting as a 'catch-all' for strings longer than four characters; however, as we've noted before, only ab, abb, and baa will be accepted.