Stubs isolate the unit under test from slow, flaky or unavailable dependencies without forcing the test to assert on interactions.
When a test depends on a payment gateway, a clock or a remote API, the test becomes slow and fragile. A stub replaces that dependency with a deterministic answer, so the test measures the unit under test, not the network.