This is the electromagnetic spectrum:
Note that radio waves are on the other side of the visible spectrum than gamma rays and xrays. The answer though is the same: penetration depends on the frequency.
Radio waves are low frequency/large-wavelength, the wavelength much larger than the interatomic distances, and the vibrational energy levels absorb frequencies down to microwaves but not radio waves. Thus radio waves can go through bulk matter for some distance before attenuation diminishes them.
By contrast the wavelength of x-rays is smaller than the interatomic distances and thus they can penetrate matter, unless they scatter directly and transfer the energy to the lattice or the atoms. Gamma rays have even smaller wavelengths and have higher penetration probability, and due to the higher energy ( E=h*nu for each photon) can do more damage when hitting a nucleus.
edit after comment
But radiations are just waves, how can we say that small wavelengths correspond to radiation passing through small gaps?
Electromagnetic radiation is not "just a wave" , it is an emergent phenomenon. In a similar way that if one looks at water waves, they are an emergent phenomenon from the motion of innumerable water molecules moving coherently, all electromagnetic radiation is a coherent confluence of zillions of photons, the quantum of electromagnetic energy. If the frequency of the EM wave is nu, each photon carries energy equal to h*nu, where h is Planck's constant a very small number h=6.62606957(29)×10^−34 Jsec .Photons are elementary particles moving with the velocity of light.
Atoms are composed of a positive nucleus and a probability cloud of electrons, organized in electron shells. A probability cloud is the square of the quantum mechanical solution of the potential nucleus-electrons and has energy levels, well defined. If the incoming radiation has a frequency/energy-of-photon that matches the energy level an electron is in, there is a high probability of a photon being absorbed and kicking an electron out.
Also why is the probability of knocking an electron out of K shell by X rays is high
K shells are the more tightly bound shells, i.e. higher energy is needed to kick off an electron. An Xray photon with the appropriate quantum of energy has a higher probability of scattering an electron from the ground shell, since the outer electrons are less tightly bound. Outer electrons quantum levels are of order of eV energies not the keV of Xrays.
K-edge describes a sudden increase in the attenuation coefficient of photons occurring at a photon energy just above the binding energy of the K shell electron of the atoms interacting with the photons. The sudden increase in attenuation is due to photoelectric absorption of the photons. For this interaction to occur, the photons must have more energy than the binding energy of the K shell electrons. A photon having an energy just above the binding energy of the electron is therefore more likely to be absorbed than a photon having an energy just below this binding energy.