They are literally just running around arranging themselves in different ways on the field, not to cause anything to happen, but to make marginal changes in the probability distribution of someone scoring. Only because the games are very long sometimes this manifests as a goal.