Thanks for the additional info.
The 15" MacBook Pro is a 2009 model. The 20" iMac is a 2007 model. To get an OS installed on either computer...you would need to purchase an OS 10.6 install DVD from Apple for $19.99 (via the apple website).
Just a side comment. Not sure what purposes you have for these computers. I'm a big fan of using older Apple computers...and getting as much "mileage" out of them as possible. This is usually from the perspective of someone who purchased a computer brand new...and doesn't want to pay the big price tag for a new computer if not necessary (yet). For someone purchasing a used older computer...this is different. Many times you will find that spending an extra $50 to $100 (on top of the price of a used computer in question)...you can get a much more "useable" computer (than the one being considered).
Personally I would consider the 2009 15" MacBook Pro to be a borderline purchase...and the 2007 20" iMac to be a "no go". Of course I don't know what prices we're talking for this computers. If someone said "Give me $50 bucks for the 20" iMac"...I would probably purchase it.

But if it's going to cost more like $200-$300...I would say..."forget-about-it".
I know your main question was how to get an OS installed on these computers (and my other comments may not be an issue for you). And the answer to the OS question is...get the $20 OS 10.6 DVD from Apple. But...you must also be aware. Apple OS versions newer than 10.6 (10.7, 10.8, 10.9, 10.10, 10.11) are basically download only. And unless you downloaded these versions previously...they will not be available to you. Apple "pulls" these older OS versions from the App Store when new OS versions are released.
You can find stuff on ebay. But this is more of a "gray-market".
HTH,
- Nick