DirectX is software and is free available. Most game CDs include the latest version of DirectX at the time and it is freely available to download from Microsoft.
The problem is, your graphics card needs to have hardware that can use the new features of each DirectX release. For example, most graphics cards today are DirectX 9. Although, as far as I know, you can download and install DirectX 10 with a DirectX 9 card, only a DirectX10 card will be able to use it to its full potential.