The idea of a finite automaton is that each state stands for a combination of following kinds of properties.
- properties of the whole string, which basically determine whether the string should be accepted or not.
- what are the last several letters of a string, which basically determine the transitions between the states when another character is appended to the string.
For the language in the question, the relevant properties are
$\quad$- whether the string contains $ab$
$\quad$- the last character of the string
So there are about $2\times 2 = 4$ states.
$\quad$ $q_{\epsilon}$: the empty string.
$\quad$ $q_{\text{no}, a}$: strings that do not contains $ab$, ending with $a$.
$\quad$ $q_{\text{no}, b}$: strings that do not contains $ab$, ending with $b$.
$\quad$ $q_{\text{yes}, a}$: strings that contain $ab$, ending with $a$.
$\quad$ $q_{\text{yes}, b}$: strings that contain $ab$, ending with $b$.
The last two states can be merged as one state
$\quad$ $q_{yes}$: strings that contain $ab$.
Note that meaningful subscripts are used to indicate the properties associated to the states. Upon seeing ${q}_{\text{no},a}$, you know immediately the input that reaches this state does not contain $ab$ and it ends with $a$.
Exercise. Define a finite automata that accepts the language $\{w\in\{a,b\}^*\mid w\text{ contains } b\text{ but does not contain } bba\text{ as a subword}\}$.