L.M.
Hi,
In the book What to Expect the First Year, it talks about that behavior as the baby finding they have rhythm. My child did it, it has stopped. I would recommend getting the book, it explains a lot of things.
Hope that helps.
L.