How do I know which ability modifier to use with an attack roll and its damage roll?

TableSACp. 122014
Attack TypeAttack RollDamage Roll
Melee weapon attackStrength mod.*Strength mod.
Ranged weapon attackDexterity mod.*Dexterity mod.
Spell attackSpellcasting ability mod.**Depends on effect
Raw data
{
  "name": "How do I know which ability modifier to use with an attack roll and its damage roll?",
  "page": 12,
  "rows": [
    [
      "Melee weapon attack",
      "Strength mod.*",
      "Strength mod."
    ],
    [
      "Ranged weapon attack",
      "Dexterity mod.*",
      "Dexterity mod."
    ],
    [
      "Spell attack",
      "Spellcasting ability mod.**",
      "Depends on effect"
    ]
  ],
  "__prop": "table",
  "source": "SAC",
  "chapter": {
    "name": "Sage Advice Compendium",
    "index": 0
  },
  "colLabels": [
    "Attack Type",
    "Attack Roll",
    "Damage Roll"
  ],
  "colStyles": [
    "col-4 text-center",
    "col-5 text-center",
    "col-3 text-center"
  ],
  "footnotes": [
    "* Add your proficiency bonus if you're using a weapon with which you're proficient.",
    "** Add your proficiency bonus. Your spellcasting ability is determined by your class or whatever feature gave you the ability to make the spell attack."
  ]
}