OS X is compatible with the previous versions of the Mac OS by using the Classic application, which runs Mac OS 9.x under emulation (the application runs in the background; any applications appear to run like OS X applications.
OS X can run many BSD or Linux software packages, when they've been compiled for the platform. Compiled binaries are normally distributed as OS X Packages; but may still require command-line configuration or compilation. Companies such as Fink provide precompiled or preformatted packages for many standard packages.