Use the Agg backend for docs builds
This uses a non-interactive Agg matplotlib backend to build docs, which avoids trying to use the default MacOS backend, which can fail in some environments.

Closes #21913.