Aiden did It & now Liam does it, my call on it has always been that as they can't wriggle around to get comfortable like an adult/toddler/child can, it is their way of getting comfortable.
For both boys I have found it normally happens as they are unwinding gettting ready for sleep. With both boys I went from patting them to patting the mattress in sleep training & I often wonder if it wasn't them repeating the sound to soothe. DH & I used to hear him do it lots when he was about 7-9mo, He'd wake whinge & then do the leg kicks & go back to sleep.
Aiden was still doing it (modified bed time only not naps) at almost 2yo, he has stopped now (replaced with sleep talking), but Liam does it.