Until now Apple charged US$19.99 to download codes for OS X Lion and OS X Mountain Lion. But now they’re free from Apple’s website.
Lion runs on Macs that came prior to the launch of Mountain Lion in 2012. Mountain Lion runs on the Macs below, but you may not be able to downgrade to it unless you completely reformat the drive. You can’t install an old OS on top of a newer one. Also, the oldest OS an M1 Mac can run is Big Sur.