For example today there are ".codes", ".farm" and ".vaijes" newly available. How do big companies like google, facebook, twitter, .. keep sure that they are the first who register their name on the new domain? Is there any contract they have with the domain registrar?
They also have the resources to sue the pants off anyone who happens to register one.
Take a look at bitsquatting and typosquatting, those are about as close as people are likely to get.
New domain spaces often have a pre register period where you can reserve a domain. If they get multiple requests for one domain they can check how has rights for this domain.
Otherwise big companies will sue you and give you some money to go away.
When a company wants a domain name which is similar to one of their trademarks, they can sue for the domain. In such a dispute over a domain name, companies with a trademark usually get preference over private people who do not. An example case was when Microsoft sued for MikeRoweSoft.com.
In that case it was about a domain name just phonetically similar to their trademark. Also, the owner of that domain was not just a squatter but had legitimate use for the domain.
Result: MS got the domain through a settlement. But reading between the lines of the settlement definitely shows that the settlement was a PR decision, not a legal one. When they wouldn't have been afraid of media backlash, Microsoft would have won.
They buy all of the domain name extension.