While they could pay a fee and receive official code and/or documentation, most likely they use existing open/free documentation and/or reverse engineer it.
Some of these file types have well-documented formats that make it easy to implement a reader/writer.
Otherwise, you can look at the output of a file, knowing what the original content was, and work back from there. Then you write up a spec, and implement it.
In both cases, you keep refining until you reach a certain percent compatibility. Even with the professionals, like Google and Microsoft, it doesn't always work perfectly. That is why many people will have each program, especially businesses who rely on 100% compatible.