The lab enables the HTTPS site with a2ensite before the certificate and key it points to have been copied. Why doesn't Apache fail to start because of that?
Because the restart is a handler: a2ensite only creates a symlink, and Apache is restarted once at the end of the play, after the certificate and key are in place.
* The handler waits until the end, so every file is in place when Apache restarts. *
The virtual host file says SSLCertificateFile /etc/ssl/certs/itia.crt. Apache reads that path when it starts or reloads, not when the site is enabled. a2ensite itself just links the file into sites-enabled/.
If the tasks restarted Apache themselves (a service: state: restarted right after a2ensite), Apache would start with a site whose certificate doesn't exist yet and fail. Because the tasks only notify, the restart is queued. The block that copies the certificate and key runs afterwards, and the handler restarts Apache once at the end, when everything is in place.
This is a second benefit of handlers besides "restart only on change": they decouple what changed from when the service picks it up, so tasks can be written in a natural order.
Go deeper:
Controlling when handlers run (official docs) โ handlers run after the tasks of the section.