There’s a couple reasons - biggest one is that the distance from the moon to the earth, and the earth to the sun, are actually always changing, and the closer the moon is, the longer the period of totality. It also depends on where you are on the globe - the moon is only going to sit in front of the sun for a certain amount of time, so the closer that time lines up with where it passes over your area, the longer it’s going to appear.