Usually, when it’s a one-off like this, the video game gets “paid” to put the stuff in their game. That payment may be in-kind advertising campaigns, etc.
For something like Need for Speed, Forza, etc, the game will be licensing the likeness of the vehicles and the company logos in the game. I don’t know the costs, but the fact that it’s also advertising will factor in.
In this case, there are a few likely scenarios:
The game director or art director or someone high up at Epic has a hard-on for the Cybertruck and really wanted it in the game. So they pursued Tesla and made a deal.
Epic wanted to add vehicles to the game and decided to go with licensed vehicles. Their merchandising people reached out to merchandising people at all the auto companies and then figured out some deals.
Someone high up at Tesla (maybe even Musk) loves, or has a kid who loves, Fortnite and decided they want the Cybertruck in the game. So they pursued Epic to make a deal.
Number 2 is most likely, but I don’t know the game well enough to know the vehicle situation in it.
For all of them, you have to factor in a bunch of details to figure out who is paying who:
who wants it more (/ power imbalance)
how much money is it going to cost to make the models, animations, etc
how much is it going to cost players to get the item
are there aspects that either company finds undesirable (E.g. sometimes car companies don’t like their cars shown with damage)
who will be doing the bulk of the marketing, and who has the marketing budget to spend on the venture
probably a lot more
So, it’s hard to say without more inside info. Games I’ve worked on have had 1 and 2, but not 3 as far as I know. I think it was pretty much an in-kind deal for the 1 situation though (like we got the likenesses, they got advertising through the game, ostensibly we sold more games with the likenesses, but I think it just stroked someone’s ego…) All of the 2 situations were done to bring in money for the game’s marketing budget / or were in-kind marketing deals, possibly bringing money directly to the bottom line, but I don’t know.