I can't figure out why this automation doesn't work

Sure! If you are using 2021.7, you can even combine the trigger for turn on and off in a single automation - taking advantage of trigger condition and trigger ID feature. See this post below-