How would you explain stateful encryption? I have recently started reading on encryption protocols and their counter attacks. I came across the term Stateful Encryption particularly used in encrypting data that is stored in the cloud. So far I think it is just another variable that is used to calculate ciphertext and gets updated after every generation and storage of ciphertext from a plaintext. Can you explain why statefulness was needed and how it solved that need?
Stateful encryption aims at reducing the number and/or volume of data exchanges and/or computational burden in recurrent communications between entities, compared to what would occur if, at the beginning of each communication chunk, everything was redone as for the first chunk. This is obtained by sharing some data, called the state, from chunk to chunk. Depending on context, "chunk" can be a block of information of some small fixed size, a packet, a session for some communication protocol like TCP/IP or HTTP...

Perhaps the simplest stateful encryption is CBC encryption with a block cipher $E$ (though that predates the term stateful encryption, which is not used for CBC). The stateless version of CBC would, for each plaintext block $P_i$, draw a random $\text{IV}_i$ and send cryptogram $(\text{IV}_i,C_i=E(\text{IV}_i\oplus P_i))$; this is secure from a confidentiality standpoint, but overall cause the ciphertext to be twice the size of the plaintext. While CBC encryption draws a single random $\text{IV}$, sends $(\text{IV},C_0=E(\text{IV}\oplus P_0))$ for the first packet, and $(C_i=E(C_{i-1}\oplus P_i))$ for all the next ones, thus reducing communication overhead to a single block. Here chunk is a block, and the state is simply the last block encrypted, initially $\text{IV}$.

The term stateful encryption has been used for similar techniques to reduce the overhead in direct encryption with asymmetric ciphers like ElGamal; but practice is to use hybrid encryption instead, since that's much more efficient computationally.

Transport Layer Security Session Resumption is a practically used form of stateful encryption. As an utter oversimplification of that, when resuming a TLS connection that got broken for some reason, one side proposes to reuse the previous session key, and if the other agrees, that saves the authenticated Diffie-Helmann key exchange (or similar) for the negotiation of that session key.