It is always the case that after you change a function cell, you must execute that cell explicitly in order for the new code to be incorporated into the runtime image. If you just call the function again without doing that, it just runs the old code. You can easily demonstrate this effect with a little experiment: take an existing function that works and introduce an obvious bug in it. Then call it again: it still works. Now click “Shift - Enter” on the modified cell and then call it again. Kaboom!
But beyond that, there is something clearly wrong here. I don’t have a theory based on the behavior you describe, but I can testify that in my code the LTSM inputs and outputs are the same shape on every iteration.