data structures – What is the difference between a state machine and a database

State machines and databases are quite different entities, and their usage (or functionality) is very different.
In this answer, I’ll just try to separate them with respect to the similarity you mention. This is by no means a comprehensive description of neither state machines nor databases.

The states of a state machine can indeed be thought of as representing data (although this is not always obvious, and sometimes state machines do not reveal what data they store in their states). However, the crucial element of a state machine is the transitions between the states, which represent the behaviour of the machine.

That is, a state machine does something. It computes. During its run (or runs, in nondeterministic models), it moves from state to state according to some predetermined set of rules, and possibly according to a given input, and this process is called a computation. At the end of the computation (if it’s finite), you might receive an output, from which you can derive some information.

For example, a Turing machine receives an input and if it halts, tells you whether the input is accepted or rejected, from which you can formalize a decision problem.
Similarly, an automaton does the same, but without external memory.

In contrast, a database merely stores data. How this storage is done, which operations are allowed on the data, and what their respective complexity is, are all interesting questions, and their answers depend on the type of database you use.
However, databases do not compute anything by themselves, they just store the data, possibly efficiently.