How does RSA padding work exactly?
There exist many standards which describe a lot of padding modes and security protocols. If you're new in that field, I strongly recommend you to study the family of PKCS standards which are the reference in the domain. There also exist other distinct standards depending of very specific application fields (Banking, mobile, Cloud, Embedding ... or Global Platforms).

Briefly, as you've certainly observed the RSA primitive is based on modular exponentiation and this operation is homomorphic in the sense that if someone knows two ciphertexts $c_1=m_1^d$ and $c_2=m_2^d$, then he can immediately deduce : $(m_1.m_2)^d= c_1.c_2=c$.
This is the essential reason to break this "homomorphism", by adding inside the plaintext some hash or other techniques.

Other security protocols allow an attacker to interact with an oracle to prove the security of the scheme. Then randomization can be included in some cases to prevent the attacker from deducing any bit of information about the plaintext when she is given the ciphertext. The subject is very vast.