How does Firebase generate the Uid?
The Firebase User ID (often called uid) is an opaque identifier for a user account. It has no connection to the underlying identity provider(s) for the account and should be treated as an opaque value.
As per IndieWeb
“Opaque” is a term often used to refer to data such as URIs or other identifiers. An identifier is opaque if it provides no information about the thing it identifies other than being a seemingly random string or number.
UUID is autogenerated based on timestamp and some entropy. UUID's can be sorted based on creation time, this helps to maintain indexes in Firebase.
UUID is not some hash of for example the email address, or facebook id or other. By removing all meaning from the uid itself, it is not dependent on any underlying properties and those properties can freely changed.
If you want to use custom UID you need to be consistent. It is recommended to not tight together user id creation and login property of some sort because the property can change, and you will have inconsistent user id.