Here's why: The fuel pump relay acts as a switch, turning the fuel pump on and off. If the relay is faulty, it might:
* Fail to initially engage: The fuel pump won't get power, preventing the engine from starting at all.
* Engage, then fail intermittently: The engine starts, but the relay fails after a short time, cutting power to the fuel pump and causing the engine to stall. This is the scenario you described.
* Overheat and fail: Prolonged use might cause the relay to overheat and fail, leading to stalling.
While other issues can cause stalling, a faulty fuel pump relay is a common and relatively easy-to-check possibility. If the car stalls soon after starting and restarts only after a delay (allowing the relay to cool down possibly), it's a strong indicator of a failing relay.