Can we use ddr 3 or ddr 2 instead of ddr ram

DDR, DDR2, and DDR3 have different pin layouts and the notches on the bottom of each type of module are different to prevent you from installing them in a slot not made for the module you are trying to use. If this notch didn't exist and you installed the wrong generation of DDR then you would damage the RAM and probably the motherboard and possibly the CPU.

These differences are because unlike different generations of SATA and PCIe the different DDR generations are very different technologies.
 

Actually DDR vs DDR2 vs DDR3 technology differences are same as SATA1 vs SATA2 vs SATA3 or PCIe1 vs PCIe2. However, they were designed for different purpose: SATA and PCIe were designed for long-term, thus the standard of the 1st version included some low-speed hand-shake to establish the common highest version. This was because the possible devices would be much broader, so forcing exact matching would be too costly (SATA can connect CDROMs, HDDs, SSDs, while PCIe can connect....well...many). Think about a 500$ PCIe1 RAID card and transition to PCIe2.
But the DDRx are always memories, which are considerably cheaper/piece (yes, I know there are some cheaper PCIe cards than some DDR modules). And not only the protocol was changed, but also some other requirements (like line termination) and extra/changed lines. So to not damage any component (like blazorthon said) they included some mechanical markers, making it impossible to damage with some common sense.