If you head to the Mac OS X Lion Installer page or the Mac OS X Mountain Lion Installer page, you can drop in and download each operating system version for free. You can still buy Mac OS X lion and Mac OS X Mountain Lion from the Apple store for approximately $20 each, but they’ve also been made available for free through Apple support documents.
Starting with Mac OS X 10.9 Mavericks, Apple started making updates to their operating system free for compatible devices.