Are the grammar in these two the same? If yes, why is there a comma in the second one and not in the first one?
Yes, they are the same. The て-form is used in both cases to connect multiple actions together (often sequentially in time). You can think of it as the English
In Japanese, the comma can be used basically whenever one wants to indicate a break in thought. It is also fairly optional. That is to say, there's no real difference in using a comma or not here. It's an optional separator.