Yes, the Mac OS and iOS versions are different programs. They can use the same documents, but the programs themselves are different, so you do have to buy each one separately.
BUT, you can run each of those versions on multiple devices. So you can run 'Mac Pages' on your iMac and your Macbook using the same copy. And you could run 'iOS Pages' on your iPad and your iPhone and your iPod all using that same copy.