A library may need to work on several operating systems and language versions, and writing a separate job for each is repetitive. A matrix runs one job definition across every combination for you. Reach for it when you must test, say, Node 18, 20 and 22 on Linux and Windows. Keep the product small, since each combination is a full job, and set fail-fast: false when you need to see every failing version.