Does a fingerprint scanner come with its own storage where fingerprints are stored?
No, but Android uses a Trusted environment, known as Trusty TEE. This secure enclave runs the Trusty operating system. The Trusty does not hand out the fingerprint data.
On hardware with support for a secure enclave, this OS will run on special parts of the hardware, unavailable to the rest of the OS. It communicates via a dedicated interface.
How does the fingerprint scanner decide which fingerprint requests from apps are legitimate?
It doesn't. That's left to the user. But the fingerprint scanner doesn't return raw fingerprint scan results to the OS. An app requests the Trusty OS to authenticate the fingerprint, using the relevant API. It then tells the app whatever the authentication succeeded or not.
When you factory reset a phone, do all the fingerprints get securely wiped?
I would imagine that wiping the device nukes any encryption keys, which will probably be stored within the TEE. This effectively makes the data unrecoverable, as it is unencrypted. I could however not find any sources for this.