I was trying to understand how the bitcoin wallet work. Since it is said that the private key it self deos not appear publicly in the blockchain, how do the system identifies it. I assume it is only used when generating degital signatures that will unlock output generated.
The network doesn't need your private key, it recognized it from the signature and the public key.
When someone send you Bitcoin, that Bitcoin is lock on that public key hash and only a valid signature can unlock that Bitcoin.
To spend the Bitcoin, the network doesn't need your private key, so instead your private key produce a signature and a public key that match the scriptpubkey, once they match each other the network allows that Bitcoin to be spend to another wallet address, this way your private key isn't sacrifice on the network and nobody will see it.
In addition I want to knw how secured it is if we generate our own random number on our computer to generate the private key. Is it safe to do that?
It's safe if you do it but randomness and entropy is very important. Why not make use of the laptop as an airgap device, no internet, no Bluetooth and then create a safe seed phrase to have addresses and their private keys. This helps you manage your private keys properly instead of bunch of keys.