I as a user as well cannot seem to buy keys from Steam though?
There are a number of legitimate sites which provide Steam keys with purchases, such as Humble Bundle, Fanatical, and Green Man Gaming. In addition, the developer/publisher of the game can generate keys and sell them however they'd like, or even give them out freely. Steam provides an API for both of these cases.
Cheap keys on reseller sites are usually one (or more) of:
- Purchased during a sale
- Purchased in a country with lower prices, but still considered the same "region"
- Included in a "bundle" which contains multiple games for dirt-cheap (Humble Bundle and Fanatical have a lot of these)
- Given away en masse by developers on sites like SteamGifts
- Leaked from some database
Only in the last case are the keys illegally obtained (and will likely be revoked). Unfortunately there's no way to tell a legitimate key apart from an illegitimate one on these reseller sites.