Why random number used in RSA padding but not in AES? I noticed that people use a random number in the RSA-OAEP padding scheme to avoid deterministic encryption. But in pkcs#7 people just use the padding size rather than some random bits. Doesn't it make AES deterministic?
They are different concepts and have different approaches. AES like any block cipher is a primitive and the encryption is performed by using the block cipher mode of operation. Like ECB,CBC,CTR,GCM,EAX...
The pkcs#7 padding or any other padding that is used to fill the last block to the block size with ambiguous remove, not designed for randomization. Even one can design a randomized padding mechanism it can affect at most 2 blocks without wasting the other blocks. Therefore not a good randomization point. Indeed, the CTR and OFB don't use padding at all.
The randomization ( probabilistic encryption) is achieved by using IV/nonce.
Since the insecure ECB doesn't use an IV, it doesn't have Indistinguishability under chosen CPA attack (Ind-CPA). This is the minimum requirement for modern Cryptography, but not enough. The other modes have IND-CPA.
Like other Authenticated Encryption modes, AES-GCM can have IND-CCA2. And we prefer the Authenticated Encryption ( with Associated Data (AEAD)) to use. The common modes are AES-GCM, ChaCha20-Poly1305, EAX, and CCM. TLS 1.3 standard has the AES-GCM, AES-CCM, and ChaCha20-Poly1305 AEAD cipher modes.
And note that Authenticated Encryption is a stronger notion, AEAD &gt; IND-CCA.
One should note that IV/nonce is necessary but not sufficient for security. For example, the CBC IV must be more than a nonce, it must be unpredictable. For the CTR mode, the (key,IV) pair must never be reused ( similar to GCM mode since it uses CTR mode inside). There is a mode against the nonce misuse:
SIV (Synthetic Initialization Vector) mode, it called a nonce-misuse resistant authenticated-encryption.