Here’s how you can think about it.
State is a part of your document, it runs like a thread embedded in the document content. The value of a state is the result of all state updates that happened in the document up until that point.
That’s why state.update returns an invisible sliver of content that you need to return and include into the document - a state update that is not ‘placed’ in the document does not happen, and ‘when’ it happens is determined by where you place it. I hope that helps make sense of it. (Example: Only figures that are placed into the document increase the value of the figure counter).
That’s also why you need context to read state, you need to use the current document position to know where on the state’s “thread” you are.
As you can see, state does not work like a regular variable in a programming language. I hope you will come to see how this makes sense for creating documents in Typst - it’s informed both by how documents are put together, and by the aggressive caching that Typst does (as explained by previous poster).