Why Is the Background Black in Flash Photos?
Flash light gets much weaker with distance — double the distance and it's a quarter as bright (the inverse-square law). Your subject is close, so they're lit; the background is far enough that almost no flash reaches it, so it records as black.
The simple physics
Light spreads out as it travels. At 3 feet your subject gets a strong burst; at 12 feet the wall behind them gets a tiny fraction of that. The camera exposes for the subject, so the under-lit background falls to black. It's the same reason close subjects overexpose.
Making the background go darker (on purpose)
Get closer to the subject, use a faster shutter, keep the background far away. This is the paparazzi / disposable look — see flash photography with a black background.
Keeping background detail
Slow the shutter so ambient light registers, raise ISO, or put the subject nearer to a lit background. This is slow-sync flash — the nightclub look.
Faking it after the fact
An AI relight can add or deepen the falloff on a normally-lit photo — Rush Flash and Flash in Flash Effect do this.
Can I get a black background in daylight with flash?
Hard with a phone, possible with a real camera by using a very fast shutter and low ISO so ambient light barely registers, then letting the flash light only the subject.