getting address from public of ScriptPubKey vs ScriptSig Recently I read some articles about BITCOIN protocol and it's transaction.
I understand(maybe it is incorrect) these rules:


An input is what we call an output when you're spending it in a
transaction.
A public key is the early form of an address.
It seem's that an "input" has two jobs: Select an Output and Unlock it.
Every transaction has a unique TXID, so by using that with a specific
output number(VOUT), we can refer to any output in the blockchain.
Each output is set with a locking script. So if we want to spend
one, we need to supply an unlocking script(ScriptSig).
ScriptSig in an input is a script that unlocks the input and
ScriptPubKey is a A script that locks the output.


if all rules that I wrote is correct, why we can generate an address which is obtained from public key in ScriptPubKey but we can't generate previous output address from the public key inside the ScriptSig?
You can't find the address from the scriptSig or input in general, because you don't know what the output was. Your question makes the assumption that every output contains a (common, but not only) P2PKH script.

If you would know the output being spent was a pay-to-pubkey-hash scriptPubKey, which is spent by revealing the full public key and a signature with it, you can indeed compute the address as the P2PKH address of that public key. But you don't know that without access to the output.

If you would know the output being spent was a P2SH scriptPubKey, which is spent by revealing the full script and its inputs, you can compute the address as the P2SH address of that script. But you don't know that without access to the output.

If you would know the output being spent was a segwit P2WPKH or P2WSH scriptPubKey, which are spent with an input that contains the public key resp. script as the last witness stack element, you can compute the address as the Bech32 address corresponding to that key or script. But you don't know that without access to the output.

If the scriptPubKey of the output being spent is not one of these specific templates (P2PKH, P2SH, segwit), the answer is simply that no address for that output exists. Addresses are a convenient human-readable form for specific types of transaction outputs that are common im payments. But they are by no means the only things supported by the Bitcoin protocol.