There could be two reasons for this, either your cookies where not completely cool or your icing is too thin. If it’s the later, you can mix in some extra icing sugar to thicken the consistency to get it stiff enough to hold it’s shape when piping.