Typically product placement agencies work either on a retainer or one-off basis. Retainer clients are preferable because it allows the agency time to educate productions on the product and its features. A brand like Nokia might be paying an agency anywhere from $20,000-$100,000+/year. This might seem like a lot, but in reality, the return on investment is worth the work the agency puts into securing a placement.
Sometimes global brands (like Nokia) might partner with an entertainment property to promote the film (we call this a promotional partnership) or Nokia could have provided 70+ devices with service for the production team to use during the filming process in exchange for placement.
Keep in mind that the producers, set decorators, and property masters have a say in the content as well. Sometimes placements are also scripted and therefore required to occur. A brand like Apple might not fit a characters scripted persona and therefore might not making on screen.
There are many other factors that come into play. Product placement agencies do a lot of the leg work in developing solid relationships with studios and production teams to secure strong placements for their clients (brands).