Ionic compounds are brittle due to the strong electrostatic forces between the positively and negatively charged ions. When a force is applied to an ionic crystal, the layers of ions shift. This movement can bring like-charged ions next to each other, creating a repulsive force that causes the crystal to shatter.
On the other hand, metals are malleable because they have a different structure. In metals, atoms are arranged in a lattice structure, but they are not held together by ionic bonds. Instead, they have a ‘sea of electrons’ that allows atoms to slide past one another when a force is applied. This ability to deform without breaking is what makes metals malleable.