A state machine is a software model of computation, and it comprises finite number states. Hence it is also called a Finite State Machine (FSM).
Since states are finite, there is a finite number of transitions among the states. Transitions are triggered by the input events fed to the state machine (FSM is an event-driven system).
A state machine also produces an output. The output produced depends on the current state of the state machine and the input events fed to the state machine.
They are used to describe situations or scenarios of your application (Modelling the life cycle of a reactive object through interconnections of states).
FSMs are helpful to model complex applications that involve lots of decision-making, producing different outputs (actions), and processing various events.
State machines are visualized through state machine diagrams in the form of state charts, which helps to communicate between non-developers and developers.
Makes it easier to visualize and implement the changes to the behavior of the project.
Complex application can be visualized as a collection of different states processing a fixed set of events and producing a fixed set of outputs.
Loose coupling: An application can be divided into multiple behaviors or state machines, and each unit can be tested separately or could be reused in other applications.
Scalable
Narrow down whole application complexity to state level complexity, analyze and implement.