Why does my child do this

Codie

So every time I give my child her bottle or something hard like a toy she always hits her knees with it I try to get her to stop by telling her it will hurt and you shouldn’t do that but she just carries on as much as I tell her don’t (just like children do) but why does she do this?