My nearly 2 year old did as well ehen he was around that age, from about 4 months till he learned to crawl at 7 months he did it, while rocking back and forth in a sitting position. For a bit there was concerns and he moved on from that and never did it again. With any movements like that, that you look at them and think oh thats a bit strange, most children do it and its common in most, what you have to watch out is for prolonged use with this "stimmings" as its commong for most to do it as they learn to move and control their body, but if it persists for a long time then i would have them checked. Same with tip toe walking, common is most kids, but if it persist it could potentially be a sign of autism if it comes with other signs. Hope that makes sense
5 months is abit early to worry. If baby still does it along with other signs after turning 1 year old then you could see a paediatrician who can give professional advice on it as they did with my son and he's been referred to be assessed for autism and is 18 months now but was referred at 16 months
My baby does that too, since 3 months. I wouldn't worry