Understanding LSTM Keras implementation
I am afraid both of your description is incorrect but the first one is the closest.

Each cell/timestep will actually produce a hidden state representation. However, this is surpressed by default on keras. You can re. As LSTM without Bidirectional wrapper produce a one-way sweep through your sequence, your output from LSTM(5) is the hidden state of the final LSTM cell(cell output not cell state). 

Now to enable outputting the sequence of hidden output similar to what you might have learned about LSTM, simply supply return_sequence=True.

To compare output shape:

Without return_sequence=True, Input shape from [batch_size,sequence_length,previous_hidden_dim] to [batch_size,hidden_dim]

With return_sequence=True,
Input shape from [batch_size,sequence_length,previous_hidden_dim] to [batch_size,sequence_length,hidden_dim]

What you are referring as "folding" of LSTM is actually iautomatically based on sequence length of previous input.

In case of any doubt on my explanation, please read the material I give you below. You can verify my description by calling model.summary().

So basically what led to your confusion is due to keras LSTM default behaviour of only outputting the final cell output.

LSTM link